FOSS-VG/src/test/nbt_tags.cpp

51 lines
1.9 KiB
C++

// Copyright 2022, FOSS-VG Developers and Contributers
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// version 3 along with this program.
// If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
#include <iostream>
#include <cstdint>
#include <vector>
#include <fstream>
#include "assert.hpp"
#include "../lib/nbt.hpp"
#include "../lib/error.hpp"
#include "../lib/javacompat.hpp"
int main(){
std::cout << "################################################################################" << std::endl;
std::cout << "NBT object tests" << std::endl;
std::cout << "################################################################################" << std::endl;
std::vector<uint8_t> vector;
NBT::Tag::Generic generic = NBT::Tag::Generic();
ASSERT(generic.getTagType() == NBT::TagType::INVALID);
ASSERT(generic.serialize(&vector).isError);
std::cout << vector.size() << std::endl;
ASSERT(generic.serialize(&vector).errorCode == ErrorCodes::INVALID_TYPE);
std::cout << vector.size() << std::endl;
ASSERT(generic.serializeWithoutHeader(&vector).isError);
std::cout << vector.size() << std::endl;
ASSERT(generic.serializeWithoutHeader(&vector).errorCode == ErrorCodes::INVALID_TYPE);
std::cout << vector.size() << std::endl;
ASSERT(vector.size() == 10);
std::cout << "Passed Generic (super type) test" << std::endl;
//?????????
return 0;
}