tests/test_map.cpp

changeset 659
4a06fd63909a
parent 658
56c62780582e
child 668
d7129285ac32
equal deleted inserted replaced
658:56c62780582e 659:4a06fd63909a
161 auto added = cxMapGet(map, key); 161 auto added = cxMapGet(map, key);
162 EXPECT_EQ(memcmp(op.value, added, strlen(op.value)), 0); 162 EXPECT_EQ(memcmp(op.value, added, strlen(op.value)), 0);
163 } else { 163 } else {
164 // execute a remove and verify that the removed element was returned (or nullptr) 164 // execute a remove and verify that the removed element was returned (or nullptr)
165 auto found = refmap.find(op.key); 165 auto found = refmap.find(op.key);
166 auto removed = cxMapRemove(map, key); 166 auto removed = cxMapRemoveAndGet(map, key);
167 if (found == refmap.end()) { 167 if (found == refmap.end()) {
168 EXPECT_EQ(removed, nullptr); 168 EXPECT_EQ(removed, nullptr);
169 } else { 169 } else {
170 EXPECT_EQ(std::string((char *) removed), found->second); 170 EXPECT_EQ(std::string((char *) removed), found->second);
171 refmap.erase(found); 171 refmap.erase(found);
305 EXPECT_EQ(s3p->length, s3.length); 305 EXPECT_EQ(s3p->length, s3.length);
306 EXPECT_EQ(s3p->ptr, s3.ptr); 306 EXPECT_EQ(s3p->ptr, s3.ptr);
307 EXPECT_NE(s3p, &s3); 307 EXPECT_NE(s3p, &s3);
308 308
309 // remove a string 309 // remove a string
310 auto r = cxMapRemove(map, cx_hash_key_str("s2")); 310 cxMapRemove(map, cx_hash_key_str("s2"));
311 EXPECT_EQ(r, nullptr);
312 311
313 // iterate 312 // iterate
314 auto ref = std::vector{s5.ptr, s3.ptr, s4.ptr}; 313 auto ref = std::vector{s5.ptr, s3.ptr, s4.ptr};
315 auto iter = cxMapIteratorValues(map); 314 auto iter = cxMapIteratorValues(map);
316 cx_foreach(cxstring*, s, iter) { 315 cx_foreach(cxstring*, s, iter) {

mercurial