aboutsummaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-09-21 17:54:52 +0200
committerGitHub <noreply@github.com>2019-09-21 17:54:52 +0200
commitfec30e37ac1d160a942777b05a7717b5395c4d99 (patch)
treebd0fcdf9778bfbea6be5f10dba6936780259c1fd /src/unittest
parent5fa614d97e13af64be490336392abe2a54fdcbc1 (diff)
downloadminetest-fec30e37ac1d160a942777b05a7717b5395c4d99.tar.gz
minetest-fec30e37ac1d160a942777b05a7717b5395c4d99.tar.bz2
minetest-fec30e37ac1d160a942777b05a7717b5395c4d99.zip
Fix AreaStore's IDs persistence (#8888)
Improve documentation Read old formats Fix free ID function. Return first gap in map
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_areastore.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/unittest/test_areastore.cpp b/src/unittest/test_areastore.cpp
index a6d4706e4..691cd69d2 100644
--- a/src/unittest/test_areastore.cpp
+++ b/src/unittest/test_areastore.cpp
@@ -128,11 +128,11 @@ void TestAreaStore::testSerialization()
VectorAreaStore store;
Area a(v3s16(-1, 0, 1), v3s16(0, 1, 2));
- a.data = "Area A";
+ a.data = "Area AA";
store.insertArea(&a);
Area b(v3s16(123, 456, 789), v3s16(32000, 100, 10));
- b.data = "Area B";
+ b.data = "Area BB";
store.insertArea(&b);
std::ostringstream os;
@@ -143,20 +143,31 @@ void TestAreaStore::testSerialization()
"\x00\x02" // Count
"\xFF\xFF\x00\x00\x00\x01" // Area A min edge
"\x00\x00\x00\x01\x00\x02" // Area A max edge
- "\x00\x06" // Area A data length
- "Area A" // Area A data
+ "\x00\x07" // Area A data length
+ "Area AA" // Area A data
"\x00\x7B\x00\x64\x00\x0A" // Area B min edge (last two swapped with max edge for sorting)
"\x7D\x00\x01\xC8\x03\x15" // Area B max edge (^)
- "\x00\x06" // Area B data length
- "Area B", // Area B data
+ "\x00\x07" // Area B data length
+ "Area BB" // Area B data
+ "\x00\x00\x00\x00" // ID A = 0
+ "\x00\x00\x00\x01", // ID B = 1
1 + 2 +
- 6 + 6 + 2 + 6 +
- 6 + 6 + 2 + 6);
+ (6 + 6 + 2 + 7) * 2 + // min/max edge, length, data
+ 2 * 4); // Area IDs
+
UASSERTEQ(const std::string &, str, str_wanted);
std::istringstream is(str);
store.deserialize(is);
- UASSERTEQ(size_t, store.size(), 4); // deserialize() doesn't clear the store
+ // deserialize() doesn't clear the store
+ // But existing IDs are overridden
+ UASSERTEQ(size_t, store.size(), 2);
+
+ Area c(v3s16(33, -2, -6), v3s16(4, 77, -76));
+ c.data = "Area CC";
+ store.insertArea(&c);
+
+ UASSERTEQ(u32, c.id, 2);
}