Skip to content

Commit

Permalink
Merge pull request #61 from Amulet-Team/fixes
Browse files Browse the repository at this point in the history
Small Fixes
  • Loading branch information
gentlegiantJGC authored Feb 21, 2024
2 parents cb294f7 + ffd9844 commit 7be20d7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:
shell: bash
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
pip install .[dev]
- name: Test with unittest
run: python -m unittest discover -v -s tests
Empty file.
8 changes: 4 additions & 4 deletions src/amulet_nbt/_nbt_encoding/_string/_cpp/write_snbt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void write_snbt_list(std::string& snbt, const CListTagPtr& tag, const std::strin
const std::vector<T>& list = std::get<std::vector<T>>(*tag);
snbt.append("[");
for (size_t i = 0; i < list.size(); i++){
snbt.append("\r\n");
snbt.append("\n");
write_indent(snbt, indent, indent_count + 1);
if constexpr (std::is_same_v<T, CByteTag>){write_byte_snbt(snbt, list[i]);} else
if constexpr (std::is_same_v<T, CShortTag>){write_short_snbt(snbt, list[i]);} else
Expand All @@ -235,7 +235,7 @@ void write_snbt_list(std::string& snbt, const CListTagPtr& tag, const std::strin
if constexpr (std::is_same_v<T, CIntArrayTagPtr>){write_int_array_snbt(snbt, list[i]);} else
if constexpr (std::is_same_v<T, CLongArrayTagPtr>){write_long_array_snbt(snbt, list[i]);}
if (i + 1 == list.size()){
snbt.append("\r\n");
snbt.append("\n");
write_indent(snbt, indent, indent_count);
} else {
snbt.append(",");
Expand Down Expand Up @@ -331,13 +331,13 @@ void write_compound_snbt(std::string& snbt, const CCompoundTagPtr& tag, const st
auto sorted = sort_compound(tag);
snbt.append("{");
for (auto it = sorted.begin(); it != sorted.end(); it++){
snbt.append("\r\n");
snbt.append("\n");
write_indent(snbt, indent, indent_count + 1);
write_key(snbt, it->first);
snbt.append(": ");
write_node_snbt(snbt, it->second, indent, indent_count + 1);
if (std::next(it) == sorted.end()){
snbt.append("\r\n");
snbt.append("\n");
write_indent(snbt, indent, indent_count);
} else {
snbt.append(",");
Expand Down
78 changes: 39 additions & 39 deletions tests/test_amulet_nbt/test_tag/test_compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,53 +777,53 @@ def test_to_snbt(self):
full_compound.to_snbt(None),
)
self.assertEqual(
"{\r\n"
" byte: 0b,\r\n"
" byte_array: [B;],\r\n"
" compound: {},\r\n"
" double: 0d,\r\n"
" float: 0f,\r\n"
" int: 0,\r\n"
" int_array: [I;],\r\n"
" list: [],\r\n"
" long: 0L,\r\n"
" long_array: [L;],\r\n"
" short: 0s,\r\n"
' string: ""\r\n'
"{\n"
" byte: 0b,\n"
" byte_array: [B;],\n"
" compound: {},\n"
" double: 0d,\n"
" float: 0f,\n"
" int: 0,\n"
" int_array: [I;],\n"
" list: [],\n"
" long: 0L,\n"
" long_array: [L;],\n"
" short: 0s,\n"
' string: ""\n'
"}",
full_compound.to_snbt(" "),
)
self.assertEqual(
"{\r\n"
" byte: 0b,\r\n"
" byte_array: [B;],\r\n"
" compound: {},\r\n"
" double: 0d,\r\n"
" float: 0f,\r\n"
" int: 0,\r\n"
" int_array: [I;],\r\n"
" list: [],\r\n"
" long: 0L,\r\n"
" long_array: [L;],\r\n"
" short: 0s,\r\n"
' string: ""\r\n'
"{\n"
" byte: 0b,\n"
" byte_array: [B;],\n"
" compound: {},\n"
" double: 0d,\n"
" float: 0f,\n"
" int: 0,\n"
" int_array: [I;],\n"
" list: [],\n"
" long: 0L,\n"
" long_array: [L;],\n"
" short: 0s,\n"
' string: ""\n'
"}",
full_compound.to_snbt(4),
)
self.assertEqual(
"{\r\n"
"\tbyte: 0b,\r\n"
"\tbyte_array: [B;],\r\n"
"\tcompound: {},\r\n"
"\tdouble: 0d,\r\n"
"\tfloat: 0f,\r\n"
"\tint: 0,\r\n"
"\tint_array: [I;],\r\n"
"\tlist: [],\r\n"
"\tlong: 0L,\r\n"
"\tlong_array: [L;],\r\n"
"\tshort: 0s,\r\n"
'\tstring: ""\r\n'
"{\n"
"\tbyte: 0b,\n"
"\tbyte_array: [B;],\n"
"\tcompound: {},\n"
"\tdouble: 0d,\n"
"\tfloat: 0f,\n"
"\tint: 0,\n"
"\tint_array: [I;],\n"
"\tlist: [],\n"
"\tlong: 0L,\n"
"\tlong_array: [L;],\n"
"\tshort: 0s,\n"
'\tstring: ""\n'
"}",
full_compound.to_snbt("\t"),
)
Expand Down

0 comments on commit 7be20d7

Please sign in to comment.