summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-08-02 21:17:38 +0200
committerljfa-ag <ljfa-ag@web.de>2015-08-02 21:17:38 +0200
commita3fb29ae603a293f12959abbc35af1bf4a156c76 (patch)
tree17cfcd56204aebee8802edf8714ce2bd107448e9
parent06644a4f989fa9fe673281859734be7a7b72aeac (diff)
downloadProject-Tick-a3fb29ae603a293f12959abbc35af1bf4a156c76.tar.gz
Project-Tick-a3fb29ae603a293f12959abbc35af1bf4a156c76.zip
Add more tests for tag
-rw-r--r--test/nbttest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/nbttest.cpp b/test/nbttest.cpp
index c253a5d59b..eeb5a84d01 100644
--- a/test/nbttest.cpp
+++ b/test/nbttest.cpp
@@ -23,6 +23,30 @@
using namespace nbt;
+void test_tag()
+{
+ ASSERT(*tag::create(tag_type::Byte) == tag_byte());
+ ASSERT(tag::create(tag_type::Null) == nullptr);
+ ASSERT(tag::create(tag_type::End) == nullptr);
+
+ tag_string tstr("foo");
+ auto cl = tstr.clone();
+ ASSERT(tstr.get() == "foo");
+ ASSERT(tstr == *cl);
+
+ cl = std::move(tstr).clone();
+ ASSERT(*cl == tag_string("foo"));
+ ASSERT(*cl != tag_string("bar"));
+
+ cl = std::move(*cl).move_clone();
+ ASSERT(*cl == tag_string("foo"));
+
+ tstr.assign(tag_string("bar"));
+ EXPECT_EXCEPTION(tstr.assign(tag_int(6)), std::bad_cast);
+ ASSERT(tstr.get() == "bar");
+ std::clog << "test_tag passed" << std::endl;
+}
+
void test_get_type()
{
ASSERT(tag_byte().get_type() == tag_type::Byte);
@@ -390,6 +414,7 @@ void test_tag_int_array()
int main()
{
+ test_tag();
test_get_type();
test_tag_primitive();
test_tag_string();