test_string.c 703 B

12345678910111213141516171819202122232425
  1. #include "dymc.h"
  2. #include <assert.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include "str.h"
  6. int main() {
  7. StringBuilder builder = new_StringBuilder();
  8. StringBuilder_append(builder, "test %d", 1);
  9. StringBuilder_append(builder, ", %d", 2);
  10. assert(strcmp("test 1, 2", StringBuilder_getString(builder)) == 0);
  11. assert(StringBuilder_size(builder) == 9);
  12. // String s = "a,bc,def";
  13. // List str_list = str_split(s, ',');
  14. // assert(vec_size(str_list) == 3);
  15. // assert(strcmp("a", vec_get(str_list, 0)) == 0);
  16. // assert(strcmp("bc", vec_get(str_list, 1)) == 0);
  17. // assert(strcmp("def", vec_get(str_list, 2)) == 0);
  18. printf("[PASSED] STRING\n");
  19. return 0;
  20. }