-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_string.cpp
More file actions
46 lines (30 loc) · 900 Bytes
/
test_string.cpp
File metadata and controls
46 lines (30 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <fstream>
#include <sstream>
#undef NDEBUG
#include <cassert>
#include "nbt.hpp"
int main() {
nbt::TagString test_string {"This is a string 🙂"};
nbt::NBT nbt {
"String Test",
{
{"string", test_string},
},
};
std::stringstream good_buffer;
good_buffer << std::ifstream {"string.nbt", std::ios::binary}.rdbuf();
std::stringstream test_buffer;
nbt.encode(test_buffer);
assert(("binary_string", good_buffer.str() == test_buffer.str()));
nbt::NBT file {good_buffer};
assert(("test_string",
nbt.data->tags.at("string") == file.data->tags.at("string")));
std::stringstream print_buffer;
print_buffer << nbt;
const std::string expected {
"\"String Test\"\n"
"<TagCompound> {\n"
" string: <TagString> This is a string 🙂\n"
"}"};
assert(("printed_string", expected == print_buffer.str()));
}