tests/test_hash_map.c

changeset 1388
edc34e904fe3
parent 1387
9bdd053820b7
equal deleted inserted replaced
1387:9bdd053820b7 1388:edc34e904fe3
505 } 505 }
506 } 506 }
507 507
508 CX_TEST(test_empty_map_iterator) { 508 CX_TEST(test_empty_map_iterator) {
509 CxMap *map = cxEmptyMap; 509 CxMap *map = cxEmptyMap;
510
511 CxMapIterator it1 = cxMapIterator(map);
512 CxMapIterator it2 = cxMapIteratorValues(map);
513 CxMapIterator it3 = cxMapIteratorKeys(map);
514 CxMapIterator it4 = cxMapMutIterator(map);
515 CxMapIterator it5 = cxMapMutIteratorValues(map);
516 CxMapIterator it6 = cxMapMutIteratorKeys(map);
517
518 CX_TEST_DO {
519 CX_TEST_ASSERT(!cxIteratorValid(it1));
520 CX_TEST_ASSERT(!cxIteratorValid(it2));
521 CX_TEST_ASSERT(!cxIteratorValid(it3));
522 CX_TEST_ASSERT(!cxIteratorValid(it4));
523 CX_TEST_ASSERT(!cxIteratorValid(it5));
524 CX_TEST_ASSERT(!cxIteratorValid(it6));
525
526 int c = 0;
527 cx_foreach(void*, data, it1) c++;
528 cx_foreach(void*, data, it2) c++;
529 cx_foreach(void*, data, it3) c++;
530 cx_foreach(void*, data, it4) c++;
531 cx_foreach(void*, data, it5) c++;
532 cx_foreach(void*, data, it6) c++;
533 CX_TEST_ASSERT(c == 0);
534 }
535 }
536
537 CX_TEST(test_null_map_iterator) {
538 CxMap *map = NULL;
510 539
511 CxMapIterator it1 = cxMapIterator(map); 540 CxMapIterator it1 = cxMapIterator(map);
512 CxMapIterator it2 = cxMapIteratorValues(map); 541 CxMapIterator it2 = cxMapIteratorValues(map);
513 CxMapIterator it3 = cxMapIteratorKeys(map); 542 CxMapIterator it3 = cxMapIteratorKeys(map);
514 CxMapIterator it4 = cxMapMutIterator(map); 543 CxMapIterator it4 = cxMapMutIterator(map);
815 cx_test_register(suite, test_hash_map_advanced_destructor_pointers); 844 cx_test_register(suite, test_hash_map_advanced_destructor_pointers);
816 cx_test_register(suite, test_empty_map_no_ops); 845 cx_test_register(suite, test_empty_map_no_ops);
817 cx_test_register(suite, test_empty_map_size); 846 cx_test_register(suite, test_empty_map_size);
818 cx_test_register(suite, test_empty_map_get); 847 cx_test_register(suite, test_empty_map_get);
819 cx_test_register(suite, test_empty_map_iterator); 848 cx_test_register(suite, test_empty_map_iterator);
849 cx_test_register(suite, test_null_map_iterator);
820 cx_test_register(suite, test_hash_map_generics); 850 cx_test_register(suite, test_hash_map_generics);
821 851
822 return suite; 852 return suite;
823 } 853 }

mercurial