test_silut.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * This is a test for silut in $package$
  3. */
  4. #include "si_test.h"
  5. #include "silut.h"
  6. TEST_FUNC(silut) {
  7. Silut * aid;
  8. static Silut lut[] = {
  9. { 0, "zero"},
  10. { 2, "two" },
  11. { 1, "one" },
  12. SILUT_DONE
  13. };
  14. static Silut lut_s[] = {
  15. { 1, "one" },
  16. { 2, "two" },
  17. { 0, "zero"},
  18. SILUT_DONE
  19. };
  20. static Silut lut_i[] = {
  21. { 0, "zero"},
  22. { 1, "one" },
  23. { 2, "two" },
  24. SILUT_DONE
  25. };
  26. aid = silut_lsearchi(lut, 55);
  27. TEST_NULL(aid);
  28. aid = silut_lsearchcstr(lut, "banana");
  29. TEST_NULL(aid);
  30. aid = silut_lsearchi(lut, 2);
  31. TEST_NOTNULL(aid);
  32. TEST_INTEQ(aid->integer, 2);
  33. TEST_STREQ(aid->string, "two");
  34. aid = silut_lsearchcstr(lut, "two");
  35. TEST_NOTNULL(aid);
  36. TEST_INTEQ(aid->integer, 2);
  37. TEST_STREQ(aid->string, "two");
  38. aid = silut_bsearchcstr(lut_s, "two");
  39. TEST_NOTNULL(aid);
  40. TEST_INTEQ(aid->integer, 2);
  41. TEST_STREQ(aid->string, "two");
  42. aid = silut_bsearchcstr(lut_s, "banana");
  43. TEST_NULL(aid);
  44. aid = silut_bsearchint(lut_i, 1);
  45. TEST_NOTNULL(aid);
  46. TEST_STREQ(aid->string, "one");
  47. TEST_INTEQ(aid->integer, 1);
  48. TEST_DONE();
  49. }
  50. int main(void) {
  51. TEST_INIT();
  52. TEST_RUN(silut);
  53. TEST_REPORT();
  54. }