From 20fb31d81b3dfcf66867b4660a887f7b113f4833 Mon Sep 17 00:00:00 2001 From: ljfa Date: Fri, 7 Aug 2015 15:24:13 +0200 Subject: Add read_compound method --- test/read_test.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'test/read_test.cpp') 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()); + 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()); + 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( -- cgit 0.0.5-2-1-g0f52