#include #include #include import nbtpp; [[nodiscard]] std::vector load_binary(std::filesystem::path path) { auto stream = std::ifstream(path, std::ios::binary); const auto file_size = std::filesystem::file_size(path); auto buffer = std::vector(file_size); stream.read(reinterpret_cast(buffer.data()), file_size); return buffer; } TEST_CASE("hello world", "[nbt.read]") { const auto data = ::load_binary("test/data/hello_world.nbt"); const auto nodes = nbtpp::parse(data); REQUIRE(nodes.size() == 2); REQUIRE(nodes[0].type == nbtpp::tag::compound); REQUIRE(nodes[0].name == "hello world"); REQUIRE(nodes[1].type == nbtpp::tag::string); REQUIRE(nodes[1].name == "name"); REQUIRE(nodes[1].as() == "Bananrama"); } /* TAG_Compound('hello world'): 1 entry { TAG_String('name'): 'Bananrama' } */