test/test_map.cpp

changeset 604
056e5f592d84
parent 595
0da254bf23e6
child 630
ac5e7f789048
--- a/test/test_map.cpp	Sun Nov 06 14:46:59 2022 +0100
+++ b/test/test_map.cpp	Sun Nov 06 16:07:32 2022 +0100
@@ -73,8 +73,7 @@
         auto keyiter = cxMapIteratorKeys(map);
         std::unordered_set<std::string> keys;
         cx_foreach(CxHashKey*, elem, keyiter) {
-            // we use that our test keys contain NULL-terminated strings
-            keys.insert(std::string(elem->data.cstr));
+            keys.insert(std::string(elem->data.cstr, elem->len));
         }
         EXPECT_EQ(keyiter.index, map->size);
         ASSERT_EQ(keys.size(), map->size);
@@ -103,7 +102,7 @@
         auto pairiter = cxMapIterator(map);
         std::unordered_map<std::string, std::string> pairs;
         cx_foreach(CxMapEntry*, entry, pairiter) {
-            pairs[std::string(entry->key->data.cstr)] = std::string((char *) entry->value);
+            pairs[std::string(entry->key->data.cstr, entry->key->len)] = std::string((char *) entry->value);
         }
         EXPECT_EQ(pairiter.index, map->size);
         ASSERT_EQ(pairs.size(), refmap.size());

mercurial