diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b9a1e4..02077b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(libnbt++ - VERSION 2.4.1) + VERSION 2.5) # supported configure options option(NBT_BUILD_SHARED "Build shared libraries" OFF) diff --git a/src/text/json_formatter.cpp b/src/text/json_formatter.cpp index beb6c46..4bcb12d 100644 --- a/src/text/json_formatter.cpp +++ b/src/text/json_formatter.cpp @@ -156,7 +156,7 @@ namespace //anonymous os << "["; for(unsigned int i = 0; i < la.size(); ++i) { - os << la[i]; + os << la[i] << "l"; if(i != la.size()-1) os << ", "; } diff --git a/test/read_test.h b/test/read_test.h index 4f71495..60516c9 100644 --- a/test/read_test.h +++ b/test/read_test.h @@ -37,7 +37,7 @@ class read_test : public CxxTest::TestSuite std::string input{ 1, //tag_type::Byte 0, //tag_type::End - 11, //tag_type::Int_Array + 12, //tag_type::Long_Array 0x0a, 0x0b, 0x0c, 0x0d, //0x0a0b0c0d in Big Endian @@ -54,7 +54,7 @@ class read_test : public CxxTest::TestSuite TS_ASSERT_EQUALS(reader.read_type(), tag_type::Byte); TS_ASSERT_EQUALS(reader.read_type(true), tag_type::End); - TS_ASSERT_EQUALS(reader.read_type(false), tag_type::Int_Array); + TS_ASSERT_EQUALS(reader.read_type(false), tag_type::Long_Array); int32_t i; reader.read_num(i); @@ -107,7 +107,7 @@ class read_test : public CxxTest::TestSuite //Tests if comp equals an extended variant of Notch's bigtest NBT void verify_bigtest_structure(const tag_compound& comp) { - TS_ASSERT_EQUALS(comp.size(), 13u); + TS_ASSERT_EQUALS(comp.size(), 14u); TS_ASSERT(comp.at("byteTest") == tag_byte(127)); TS_ASSERT(comp.at("shortTest") == tag_short(32767)); @@ -138,6 +138,9 @@ class read_test : public CxxTest::TestSuite TS_ASSERT(comp.at("intArrayTest") == tag_int_array( {0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f})); + + TS_ASSERT(comp.at("longArrayTest") == tag_long_array( + {0x0decafc0ffeebabe, static_cast(0xdeadbeefbaadf00d)})); } void test_read_bigtest() @@ -216,6 +219,7 @@ class read_test : public CxxTest::TestSuite "Even though unprovided for by NBT, the library should also handle " "the case where the file consists of something else than tag_compound")); } + void test_read_gzip() { #ifdef NBT_HAVE_ZLIB diff --git a/test/testfiles/bigtest.nbt b/test/testfiles/bigtest.nbt index de1a912..7647bcc 100644 Binary files a/test/testfiles/bigtest.nbt and b/test/testfiles/bigtest.nbt differ diff --git a/test/testfiles/bigtest.zlib b/test/testfiles/bigtest.zlib index 36aeee5..87aea9a 100644 Binary files a/test/testfiles/bigtest.zlib and b/test/testfiles/bigtest.zlib differ diff --git a/test/testfiles/bigtest_uncompr b/test/testfiles/bigtest_uncompr index dc1c9c1..1e378b4 100644 Binary files a/test/testfiles/bigtest_uncompr and b/test/testfiles/bigtest_uncompr differ diff --git a/test/testfiles/littletest_uncompr b/test/testfiles/littletest_uncompr index 86619e9..2f1bd61 100644 Binary files a/test/testfiles/littletest_uncompr and b/test/testfiles/littletest_uncompr differ diff --git a/test/write_test.h b/test/write_test.h index a302891..b9be132 100644 --- a/test/write_test.h +++ b/test/write_test.h @@ -44,7 +44,7 @@ class read_test : public CxxTest::TestSuite writer.write_type(tag_type::End); writer.write_type(tag_type::Long); - writer.write_type(tag_type::Int_Array); + writer.write_type(tag_type::Long_Array); writer.write_num(int64_t(0x0102030405060708)); @@ -54,7 +54,7 @@ class read_test : public CxxTest::TestSuite std::string expected{ 0, //tag_type::End 4, //tag_type::Long - 11, //tag_type::Int_Array + 12, //tag_type::Long_Array 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, //0x0102030405060708 in Big Endian @@ -147,6 +147,15 @@ class read_test : public CxxTest::TestSuite })); os.str(""); + //tag_long_array + writer.write_payload(tag_long_array{0x0102030405060708, 0x090a0b0c0d0e0f10}); + TS_ASSERT_EQUALS(os.str(), (std::string{ + 0x00, 0x00, 0x00, 0x02, //length in Big Endian + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 + })); + os.str(""); + //tag_list writer.write_payload(tag_list()); //empty list with undetermined type, should be written as list of tag_end writer.write_payload(tag_list(tag_type::Int)); //empty list of tag_int