test_tree.c 807 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Description:
  3. * Tests for the SiTree.
  4. *
  5. * Author: Beoran <beoran@rubyforge.org>, (C) 2011
  6. *
  7. * Copyright: See COPYING file that comes with this distribution
  8. *
  9. */
  10. #include <stdio.h>
  11. #include <stddef.h>
  12. #include "si_test.h"
  13. #include "si_tree.h"
  14. TEST_FUNC(sitree) {
  15. char * s1 = "Hello";
  16. char * s2 = "World";
  17. char * s3 = "This";
  18. char * s4 = "Is";
  19. char * s5 = "Me";
  20. SiTree * t1 = sitree_new(s1);
  21. SiTree * t2 = NULL;
  22. SiTree * t3 = NULL;
  23. TEST_NOTNULL(t1);
  24. TEST_NOTNULL(sitree_data(t1));
  25. t2 = sitree_add(t1, s2);
  26. t3 = sitree_add(t2, s3);
  27. TEST_NOTNULL(t2);
  28. TEST_STREQ(sitree_data(t1), s1);
  29. TEST_NOTNULL(t3);
  30. TEST_STREQ(sitree_data(t3), s3);
  31. sitree_free(t1);
  32. TEST_DONE();
  33. }
  34. int main(void) {
  35. TEST_INIT();
  36. TEST_RUN(sitree);
  37. TEST_REPORT();
  38. }