test_tree_map.c 703 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "tree_map.h"
  2. #include <assert.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include "gc_prelude.h"
  6. int main() {
  7. TreeMap dict = new_TreeMap((CompareFunc)strcmp);
  8. Integer i = new_Integer(1);
  9. TreeMap_set(dict, "1", i);
  10. i = new_Integer(2);
  11. TreeMap_set(dict, "2", i);
  12. i = new_Integer(3);
  13. TreeMap_set(dict, "3", i);
  14. i = new_Integer(4);
  15. TreeMap_set(dict, "4", i);
  16. assert(*(Integer)TreeMap_get(dict, "3") == 3);
  17. TreeMapIter iter = TreeMap_begin(dict);
  18. for (int i = 1; i <= 4; i++) {
  19. assert(*(Integer)TreeMapIter_getValue(iter) == i);
  20. iter = TreeMap_next(dict, iter);
  21. }
  22. printf("[PASSED] TreeMap\n");
  23. return 0;
  24. }