tests/test_map.cpp

changeset 706
8c6edaccaef1
parent 691
65baf7f45ac8
child 707
87eb4bdb2d0e
equal deleted inserted replaced
705:0d5447230044 706:8c6edaccaef1
470 EXPECT_EQ(map->size, 0); 470 EXPECT_EQ(map->size, 0);
471 471
472 cxMapDestroy(map); 472 cxMapDestroy(map);
473 EXPECT_TRUE(allocator.verify()); 473 EXPECT_TRUE(allocator.verify());
474 } 474 }
475
476 TEST(EmptyMap, Size) {
477 auto map = cxEmptyMap;
478
479 EXPECT_EQ(map->size, 0);
480 }
481
482 TEST(EmptyMap, Iterator) {
483 auto map = cxEmptyMap;
484
485 auto it1 = cxMapIterator(map);
486 auto it2 = cxMapIteratorValues(map);
487 auto it3 = cxMapIteratorKeys(map);
488 auto it4 = cxMapMutIterator(map);
489 auto it5 = cxMapMutIteratorValues(map);
490 auto it6 = cxMapMutIteratorKeys(map);
491
492 EXPECT_FALSE(cxIteratorValid(it1));
493 EXPECT_FALSE(cxIteratorValid(it2));
494 EXPECT_FALSE(cxIteratorValid(it3));
495 EXPECT_FALSE(cxIteratorValid(it4));
496 EXPECT_FALSE(cxIteratorValid(it5));
497 EXPECT_FALSE(cxIteratorValid(it6));
498
499 int c = 0;
500 cx_foreach(void*, data, it1) c++;
501 cx_foreach(void*, data, it2) c++;
502 cx_foreach(void*, data, it3) c++;
503 cx_foreach(void*, data, it4) c++;
504 cx_foreach(void*, data, it5) c++;
505 cx_foreach(void*, data, it6) c++;
506 EXPECT_EQ(c, 0);
507 }
508
509 TEST(EmptyMap, NoOps) {
510 auto map = cxEmptyMap;
511
512 ASSERT_NO_FATAL_FAILURE(cxMapClear(map));
513 ASSERT_NO_FATAL_FAILURE(cxMapRehash(map));
514 ASSERT_NO_FATAL_FAILURE(cxMapDestroy(map));
515 }
516
517 TEST(EmptyMap, Get) {
518 auto map = cxEmptyMap;
519
520 CxHashKey key = cx_hash_key_str("test");
521 EXPECT_EQ(cxMapGet(map, key), nullptr);
522 }

mercurial