test_str.c 571 B

1234567891011121314151617181920212223
  1. #include "dymc.h"
  2. #include <assert.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. int main() {
  6. void *ss = new_ss();
  7. ss_add(ss, "test %d", 1);
  8. ss_add(ss, ", %d", 2);
  9. assert(strcmp("test 1, 2", ss_cstr(ss)) == 0);
  10. assert(ss_size(ss) == 9);
  11. const char *s = "a,bc,def";
  12. void *str_list = str_split(s, ',');
  13. assert(vec_size(str_list) == 3);
  14. assert(strcmp("a", vec_get(str_list, 0)) == 0);
  15. assert(strcmp("bc", vec_get(str_list, 1)) == 0);
  16. assert(strcmp("def", vec_get(str_list, 2)) == 0);
  17. printf("[PASSED] str\n");
  18. return 0;
  19. }