summaryrefslogtreecommitdiff
path: root/test/read_test.cpp
diff options
context:
space:
mode:
authorljfa <ljfa-ag@web.de>2015-08-07 15:24:13 +0200
committerljfa <ljfa-ag@web.de>2015-08-07 15:31:36 +0200
commit20fb31d81b3dfcf66867b4660a887f7b113f4833 (patch)
tree6ac975a3acce213080c5673962c37edd1fb95956 /test/read_test.cpp
parentc596c4f7ae529e2dd9976c1963634825595c2218 (diff)
downloadProject-Tick-20fb31d81b3dfcf66867b4660a887f7b113f4833.tar.gz
Project-Tick-20fb31d81b3dfcf66867b4660a887f7b113f4833.zip
Add read_compound method
Diffstat (limited to 'test/read_test.cpp')
-rw-r--r--test/read_test.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/test/read_test.cpp b/test/read_test.cpp
index ae900a502d..d95c762d43 100644
--- a/test/read_test.cpp
+++ b/test/read_test.cpp
@@ -140,10 +140,9 @@ void test_read_bigtest()
ASSERT(file);
nbt::io::stream_reader reader(file);
- auto pair = reader.read_tag();
+ auto pair = reader.read_compound();
ASSERT(pair.first == "Level");
- ASSERT(pair.second->get_type() == tag_type::Compound);
- verify_bigtest_structure(pair.second->as<tag_compound>());
+ verify_bigtest_structure(*pair.second);
}
void test_read_littletest()
@@ -153,10 +152,10 @@ void test_read_littletest()
ASSERT(file);
nbt::io::stream_reader reader(file, endian::little);
- auto pair = reader.read_tag();
+ auto pair = reader.read_compound();
ASSERT(pair.first == "Level");
ASSERT(pair.second->get_type() == tag_type::Compound);
- verify_bigtest_structure(pair.second->as<tag_compound>());
+ verify_bigtest_structure(*pair.second);
}
void test_read_errors()
@@ -197,8 +196,14 @@ void test_read_misc()
std::ifstream file;
nbt::io::stream_reader reader(file);
+ //Toplevel tag other than compound
file.open("toplevel_string", std::ios::binary);
- ASSERT(file);
+ EXPECT_EXCEPTION(reader.read_compound(), io::input_error);
+ ASSERT(!file);
+
+ //Rewind and try again with read_tag
+ file.clear();
+ ASSERT(file.seekg(0));
auto pair = reader.read_tag();
ASSERT(pair.first == "Test (toplevel tag_string)");
ASSERT(*pair.second == tag_string(