Fix issue #2 on GitHub

This commit is contained in:
ktlo
2021-09-28 16:08:55 +00:00
parent 2ddbed3f59
commit 57561c859f
4 changed files with 28 additions and 2 deletions

View File

@@ -43,6 +43,8 @@
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp",
"config.cpp.in": "cpp"
"config.cpp.in": "cpp",
"cinttypes": "cpp",
"map": "cpp"
}
}

View File

@@ -217,6 +217,12 @@ template <typename number_t>
std::vector<number_t> load_array_text(std::istream & input) {
std::vector<number_t> result;
for (;;) {
skip_space(input);
char c = cheof(input);
input.putback(c);
if (c == ']') {
break;
}
result.push_back(load_text<number_t>(input));
skip_space(input);
char next = cheof(input);

17
test/issue2.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include <sstream>
#include "nbt.hpp"
#include "test.hpp"
using namespace nbt;
test {
std::stringstream input(R"({ "voidByteArray": [B; ] })");
tags::compound_tag root;
input >> contexts::mojangson >> root;
std::string key("voidByteArray");
auto & bytes = root.get<std::vector<std::int8_t>>(key);
assert_true(bytes.empty());
std::cout << contexts::mojangson << root;
}

View File

@@ -1,5 +1,6 @@
test_names = [
'nbt'
'nbt',
'issue2'
]
test_files = []