summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-08-11 14:50:10 +0200
committerljfa-ag <ljfa-ag@web.de>2015-08-11 14:50:10 +0200
commit97c69bd53bae79a897faef9d8224aacb8e3b2c90 (patch)
tree020fb4ede3daeb1202fb91dff7ab81ecd2be484d
parent7c320c9c058d6f7e151860a29cb35b136011e955 (diff)
downloadProject-Tick-97c69bd53bae79a897faef9d8224aacb8e3b2c90.tar.gz
Project-Tick-97c69bd53bae79a897faef9d8224aacb8e3b2c90.zip
Create broader test case for formatter
-rw-r--r--test/format_test.cpp56
1 files changed, 49 insertions, 7 deletions
diff --git a/test/format_test.cpp b/test/format_test.cpp
index 9f79c66c60..b1638efd4c 100644
--- a/test/format_test.cpp
+++ b/test/format_test.cpp
@@ -19,22 +19,64 @@
*/
#include "microtest.h"
//#include "text/json_formatter.h"
-#include "io/stream_reader.h"
+//#include "io/stream_reader.h"
#include <fstream>
#include <iostream>
+#include <limits>
#include "nbt_tags.h"
using namespace nbt;
int main()
{
- std::ifstream file("bigtest_uncompr", std::ios::binary);
- ASSERT(file);
- std::string key;
- std::unique_ptr<tag_compound> comp;
- std::tie(key, comp) = io::stream_reader(file).read_compound();
+ //TODO: Write that into a file
+ tag_compound comp{
+ {"byte", tag_byte(-128)},
+ {"short", tag_short(-32768)},
+ {"int", tag_int(-2147483648)},
+ {"long", tag_long(-9223372036854775808U)},
+
+ {"float 1", 1.618034f},
+ {"float 2", 6.626070e-34f},
+ {"float 3", 2.273737e+29f},
+ {"float 4", -std::numeric_limits<float>::infinity()},
+ {"float 5", std::numeric_limits<float>::quiet_NaN()},
+
+ {"double 1", 3.141592653589793},
+ {"double 2", 1.749899444387479e-193},
+ {"double 3", 2.850825855152578e+175},
+ {"double 4", -std::numeric_limits<double>::infinity()},
+ {"double 5", std::numeric_limits<double>::quiet_NaN()},
+
+ {"string 1", "Hello World! \u00E4\u00F6\u00FC\u00DF"},
+ {"string 2", "String with\nline breaks\tand tabs"},
+
+ {"byte array", tag_byte_array{12, 13, 14, 15, 16}},
+ {"int array", tag_int_array{0x0badc0de, -0x0dedbeef, 0x1badbabe}},
+
+ {"list (empty)", tag_list::of<tag_byte_array>({})},
+ {"list (float)", tag_list{2.0f, 1.0f, 0.5f, 0.25f}},
+ {"list (list)", tag_list::of<tag_list>({
+ {},
+ {4, 5, 6},
+ {tag_compound{{"egg", "ham"}}, tag_compound{{"foo", "bar"}}}
+ })},
+ {"list (compound)", tag_list::of<tag_compound>({
+ {{"created-on", 42}, {"names", tag_list{"Compound", "tag", "#0"}}},
+ {{"created-on", 45}, {"names", tag_list{"Compound", "tag", "#1"}}}
+ })},
+
+ {"compound (empty)", tag_compound()},
+ {"compound (nested)", tag_compound{
+ {"key", "value"},
+ {"key with \u00E4\u00F6\u00FC", tag_byte(-1)},
+ {"key with\nnewline and\ttab", tag_compound{}}
+ }},
+
+ {"null", nullptr}
+ };
std::cout << "----- default operator<<:\n";
- std::cout << *comp;
+ std::cout << comp;
std::cout << "\n-----" << std::endl;
}