test_pointergrid.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * This is a test for pointergrid in $package$
  3. */
  4. #include "si_test.h"
  5. #include "pointergrid.h"
  6. TEST_FUNC(pointergrid) {
  7. PointerGrid matrix_struct;
  8. PointerGrid * matrix = &matrix_struct;
  9. int i1 = 123;
  10. int i2 = 234;
  11. int i3 = 354;
  12. int i4 = 456;
  13. void * get;
  14. void * p1 = &i1;
  15. void * p2 = &i2;
  16. void * p3 = &i3;
  17. void * p4 = &i4;
  18. TEST_NOTNULL(pointergrid_init(matrix, 5, 7));
  19. TEST_FALSE(pointergrid_put(matrix, 3, 4, p1));
  20. TEST_FALSE(pointergrid_put(matrix, 0, 0, p2));
  21. TEST_TRUE(pointergrid_put(matrix, 5, 4, p3));
  22. TEST_TRUE(pointergrid_put(matrix, 1, 7, p3));
  23. TEST_TRUE(pointergrid_put(matrix, 10, 20, p4));
  24. TEST_PTREQ(p1, pointergrid_getraw(matrix, 3, 4));
  25. TEST_PTREQ(p2, pointergrid_getraw(matrix, 0, 0));
  26. TEST_FALSE(pointergrid_get(matrix, 3, 4, &get));
  27. TEST_PTREQ(p1, get);
  28. TEST_FALSE(pointergrid_get(matrix, 0, 0, &get));
  29. TEST_PTREQ(p2, get);
  30. TEST_TRUE(pointergrid_get(matrix, 5, 4, &get));
  31. TEST_TRUE(pointergrid_get(matrix, 1, 7, &get));
  32. TEST_TRUE(pointergrid_get(matrix, 10, 20, &get));
  33. TEST_NOTNULL(pointergrid_done(matrix, NULL));
  34. TEST_DONE();
  35. }
  36. int main(void) {
  37. TEST_INIT();
  38. TEST_RUN(pointergrid);
  39. TEST_REPORT();
  40. }