test_ses.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * This is a test for ses in $package$
  3. */
  4. #include "si_test.h"
  5. #include "ses.h"
  6. TEST_FUNC(ses) {
  7. char * buf;
  8. size_t size;
  9. size_t space;
  10. TEST_NOTNULL(ses_new(&buf, &size, &space, "he"));
  11. TEST_INTEQ(2, size);
  12. TEST_ASSERT(space > size);
  13. TEST_NOTNULL(ses_append_cstr(&buf, &size, &space, "llo"));
  14. TEST_INTEQ(5, size);
  15. TEST_ASSERT(space > size);
  16. TEST_NOTNULL(ses_append_buf(&buf, &size, &space, " world", 5));
  17. TEST_INTEQ(10, size);
  18. TEST_ASSERT(space > size);
  19. TEST_NOTNULL(ses_append_char(&buf, &size, &space, 'd'));
  20. TEST_STREQ("hello world", buf);
  21. TEST_INTEQ(11, size);
  22. TEST_ASSERT(space > size);
  23. TEST_NOTNULL(ses_make_empty(&buf, &size, &space));
  24. TEST_STREQ("", buf);
  25. TEST_INTEQ(0, size);
  26. TEST_ASSERT(space > size);
  27. TEST_NOTNULL(ses_read_filename(&buf, &size, &space, "test/test_ses.txt"));
  28. TEST_STREQ("input\nfrom file\n", buf);
  29. ses_free(&buf, &size, &space);
  30. TEST_INTEQ(0, size);
  31. TEST_INTEQ(0, space);
  32. TEST_DONE();
  33. }
  34. int main(void) {
  35. TEST_INIT();
  36. TEST_RUN(ses);
  37. TEST_REPORT();
  38. }