test_hatab.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * This is a test for hatab in $package$
  3. */
  4. #include "si_test.h"
  5. #include "hatab.h"
  6. TEST_FUNC(hatab) {
  7. Hatab * map;
  8. int i[] = { 123, 456, 789, 1011, 1213 };
  9. map = hatab_newroom(NULL, 3, 3);
  10. TEST_NOTNULL(map);
  11. TEST_NOTNULL(hatab_put(map, "123", i));
  12. TEST_NOTNULL(hatab_put(map, "456", i+1));
  13. TEST_NOTNULL(hatab_put(map, "789", i+2));
  14. TEST_NOTNULL(hatab_put(map, "1011", i+3));
  15. TEST_NOTNULL(hatab_put(map, "1213", i+4));
  16. TEST_PTREQ(hatab_get(map, "123"), i);
  17. TEST_PTREQ(hatab_get(map, "456"), i+1);
  18. TEST_PTREQ(hatab_get(map, "789"), i+2);
  19. TEST_PTREQ(hatab_get(map, "1011"), i+3);
  20. TEST_PTREQ(hatab_get(map, "1213"), i+4);
  21. TEST_NOTNULL(hatab_drop(map, "456"));
  22. TEST_NULL(hatab_get(map, "456"));
  23. TEST_NOTNULL(hatab_put(map, "456", i+1));
  24. TEST_NOTNULL(hatab_put(map, "456", i+1));
  25. TEST_NOTNULL(hatab_put(map, "1011", i+3));
  26. TEST_PTREQ(hatab_get(map, "1011"), i+3);
  27. hatab_free(map);
  28. TEST_DONE();
  29. }
  30. int main(void) {
  31. TEST_INIT();
  32. TEST_RUN(hatab);
  33. TEST_REPORT();
  34. }