summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-06-27 00:10:21 +0200
committerljfa-ag <ljfa-ag@web.de>2015-06-27 00:10:21 +0200
commitb600712fad86f186730ff4f9e6a52dde959187ce (patch)
treeb035d919c7fc1f82d06abea7cf317fe137ec5ff4
parentc455aeed051a1843cb0cc8907fb534f6cca72698 (diff)
downloadProject-Tick-b600712fad86f186730ff4f9e6a52dde959187ce.tar.gz
Project-Tick-b600712fad86f186730ff4f9e6a52dde959187ce.zip
Create preliminary tag_compound tests
not working yet, the class design needs to be fleshed out first
-rw-r--r--test/nbttest.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/test/nbttest.cpp b/test/nbttest.cpp
index ea4ad85629..326ddb66de 100644
--- a/test/nbttest.cpp
+++ b/test/nbttest.cpp
@@ -34,7 +34,7 @@ void test_get_type()
//ASSERT(tag_byte_array().get_type() == tag_type::Byte_Array);
ASSERT(tag_string().get_type() == tag_type::String);
//ASSERT(tag_list().get_type() == tag_type::List);
- //ASSERT(tag_compound().get_type() == tag_type::Compound);
+ ASSERT(tag_compound().get_type() == tag_type::Compound);
//ASSERT(tag_int_array().get_type() == tag_type::Int_Array);
}
@@ -74,9 +74,39 @@ void test_tag_string()
ASSERT(tag_string() == "");
}
+void test_tag_compound()
+{
+ //Preliminary
+ //Doesn't work yet, but this is the syntax I would like to have:
+ tag_compound comp{{"foo", int16_t(12)}, {"bar", "baz"}, {"baz", -2.0}};
+
+ ASSERT(comp["foo"].get_type() == tag_type::Short);
+ ASSERT((int)comp["foo"] == 12);
+ ASSERT((int16_t)comp["foo"] == int16_t(12));
+ ASSERT(comp["foo"] == int8_t(12));
+ ASSERT(comp["foo"] == 12);
+ ASSERT(comp["foo"] != "12");
+
+ ASSERT(comp["bar"].get_type() == tag_type::String);
+ ASSERT((std::string)comp["bar"] == "baz");
+ ASSERT(comp["bar"] == "baz");
+ ASSERT(comp["bar"] != 0);
+
+ ASSERT(comp["baz"].get_type() == tag_type::Double);
+ ASSERT((double)comp["baz"] == -2.0);
+ ASSERT(comp["baz"] == -2.0f);
+ ASSERT(comp["baz"] == -2);
+ ASSERT(comp["baz"] != "-2");
+
+ comp["quux"] = tag_compound{{"Hello", "World"}};
+ ASSERT(comp["quux"].get_type() == tag_type::Compound);
+ ASSERT(comp["quux"]["Hello"] == "World");
+}
+
int main()
{
test_get_type();
test_tag_primitive();
test_tag_string();
+ test_tag_compound();
}