tests/test_string.c

changeset 1671
cf19b7820ff0
parent 1668
3ffdfe1776b4
equal deleted inserted replaced
1670:56f55f2f70c0 1671:cf19b7820ff0
1023 CxStrtokCtx ctx = cx_strtok(str, delim, 10); 1023 CxStrtokCtx ctx = cx_strtok(str, delim, 10);
1024 cx_strtok_delim(&ctx, delim_more, 2); 1024 cx_strtok_delim(&ctx, delim_more, 2);
1025 bool ret; 1025 bool ret;
1026 cxmutstr tok; 1026 cxmutstr tok;
1027 1027
1028 ret = cx_strtok_next_m(&ctx, &tok); 1028 ret = cx_strtok_next(&ctx, &tok);
1029 CX_TEST_ASSERT(ret); 1029 CX_TEST_ASSERT(ret);
1030 CX_TEST_ASSERT(0 == cx_strcmp(tok, "an")); 1030 CX_TEST_ASSERT(0 == cx_strcmp(tok, "an"));
1031 CX_TEST_ASSERT(ctx.pos == 0); 1031 CX_TEST_ASSERT(ctx.pos == 0);
1032 CX_TEST_ASSERT(ctx.next_pos == 3); 1032 CX_TEST_ASSERT(ctx.next_pos == 3);
1033 CX_TEST_ASSERT(ctx.delim_pos == 2); 1033 CX_TEST_ASSERT(ctx.delim_pos == 2);
1034 CX_TEST_ASSERT(ctx.found == 1); 1034 CX_TEST_ASSERT(ctx.found == 1);
1035 test_toupper(tok); 1035 test_toupper(tok);
1036 1036
1037 ret = cx_strtok_next_m(&ctx, &tok); 1037 ret = cx_strtok_next(&ctx, &tok);
1038 CX_TEST_ASSERT(ret); 1038 CX_TEST_ASSERT(ret);
1039 CX_TEST_ASSERT(0 == cx_strcmp(tok, "arbitrarily")); 1039 CX_TEST_ASSERT(0 == cx_strcmp(tok, "arbitrarily"));
1040 CX_TEST_ASSERT(ctx.pos == 3); 1040 CX_TEST_ASSERT(ctx.pos == 3);
1041 CX_TEST_ASSERT(ctx.next_pos == 15); 1041 CX_TEST_ASSERT(ctx.next_pos == 15);
1042 CX_TEST_ASSERT(ctx.delim_pos == 14); 1042 CX_TEST_ASSERT(ctx.delim_pos == 14);
1043 CX_TEST_ASSERT(ctx.found == 2); 1043 CX_TEST_ASSERT(ctx.found == 2);
1044 test_toupper(tok); 1044 test_toupper(tok);
1045 1045
1046 ret = cx_strtok_next_m(&ctx, &tok); 1046 ret = cx_strtok_next(&ctx, &tok);
1047 CX_TEST_ASSERT(ret); 1047 CX_TEST_ASSERT(ret);
1048 CX_TEST_ASSERT(0 == cx_strcmp(tok, "")); 1048 CX_TEST_ASSERT(0 == cx_strcmp(tok, ""));
1049 CX_TEST_ASSERT(ctx.pos == 15); 1049 CX_TEST_ASSERT(ctx.pos == 15);
1050 CX_TEST_ASSERT(ctx.next_pos == 17); 1050 CX_TEST_ASSERT(ctx.next_pos == 17);
1051 CX_TEST_ASSERT(ctx.delim_pos == 15); 1051 CX_TEST_ASSERT(ctx.delim_pos == 15);
1052 CX_TEST_ASSERT(ctx.found == 3); 1052 CX_TEST_ASSERT(ctx.found == 3);
1053 test_toupper(tok); 1053 test_toupper(tok);
1054 1054
1055 ret = cx_strtok_next_m(&ctx, &tok); 1055 ret = cx_strtok_next(&ctx, &tok);
1056 CX_TEST_ASSERT(ret); 1056 CX_TEST_ASSERT(ret);
1057 CX_TEST_ASSERT(0 == cx_strcmp(tok, "separated")); 1057 CX_TEST_ASSERT(0 == cx_strcmp(tok, "separated"));
1058 CX_TEST_ASSERT(ctx.pos == 17); 1058 CX_TEST_ASSERT(ctx.pos == 17);
1059 CX_TEST_ASSERT(ctx.next_pos == 27); 1059 CX_TEST_ASSERT(ctx.next_pos == 27);
1060 CX_TEST_ASSERT(ctx.delim_pos == 26); 1060 CX_TEST_ASSERT(ctx.delim_pos == 26);
1061 CX_TEST_ASSERT(ctx.found == 4); 1061 CX_TEST_ASSERT(ctx.found == 4);
1062 test_toupper(tok); 1062 test_toupper(tok);
1063 1063
1064 ret = cx_strtok_next_m(&ctx, &tok); 1064 ret = cx_strtok_next(&ctx, &tok);
1065 CX_TEST_ASSERT(ret); 1065 CX_TEST_ASSERT(ret);
1066 CX_TEST_ASSERT(0 == cx_strcmp(tok, "string")); 1066 CX_TEST_ASSERT(0 == cx_strcmp(tok, "string"));
1067 CX_TEST_ASSERT(ctx.pos == 27); 1067 CX_TEST_ASSERT(ctx.pos == 27);
1068 CX_TEST_ASSERT(ctx.next_pos == 33); 1068 CX_TEST_ASSERT(ctx.next_pos == 33);
1069 CX_TEST_ASSERT(ctx.delim_pos == 33); 1069 CX_TEST_ASSERT(ctx.delim_pos == 33);
1070 CX_TEST_ASSERT(ctx.found == 5); 1070 CX_TEST_ASSERT(ctx.found == 5);
1071 test_toupper(tok); 1071 test_toupper(tok);
1072 1072
1073 ret = cx_strtok_next_m(&ctx, &tok); 1073 ret = cx_strtok_next(&ctx, &tok);
1074 CX_TEST_ASSERT(!ret); 1074 CX_TEST_ASSERT(!ret);
1075 CX_TEST_ASSERT(ctx.pos == 27); 1075 CX_TEST_ASSERT(ctx.pos == 27);
1076 CX_TEST_ASSERT(ctx.next_pos == 33); 1076 CX_TEST_ASSERT(ctx.next_pos == 33);
1077 CX_TEST_ASSERT(ctx.delim_pos == 33); 1077 CX_TEST_ASSERT(ctx.delim_pos == 33);
1078 CX_TEST_ASSERT(ctx.found == 5); 1078 CX_TEST_ASSERT(ctx.found == 5);

mercurial