Skip to content

Commit 1d00d93

Browse files
committed
add test with quotes
1 parent affd048 commit 1d00d93

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/test.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ static const test_str_t commands[] = {
3737
"longer text",
3838
},
3939
},
40+
{
41+
.command = "test 123 \"longer text with \\\" quotes\"\n",
42+
.args_list =
43+
{
44+
"test",
45+
"123",
46+
"longer text with \\\" quotes",
47+
},
48+
},
4049
};
4150
static uint32_t current_cmd_index;
4251

@@ -50,18 +59,18 @@ static uint32_t current_cmd_index;
5059
int32_t
5160
prv_test_cmd(int32_t argc, char** argv) {
5261
const test_str_t* cmd = &commands[current_cmd_index];
53-
size_t cmd_args_count = 0;
62+
int32_t cmd_args_count;
5463

5564
/* Get list of arguments from test command */
56-
for (cmd_args_count; cmd->args_list[cmd_args_count] != NULL; ++cmd_args_count) {}
65+
for (cmd_args_count = 0; cmd->args_list[cmd_args_count] != NULL; ++cmd_args_count) {}
5766
if (cmd_args_count != argc) {
5867
printf("Test failed: Expected argument count (%02u) does not match actual argument count (%02u)\r\n",
5968
(unsigned)cmd_args_count, (unsigned)argc);
6069
return -1;
6170
}
6271

6372
/* Check if parameters match */
64-
for (size_t idx = 0; idx < argc; ++idx) {
73+
for (int32_t idx = 0; idx < argc; ++idx) {
6574
/* Argument failed */
6675
if (strcmp(cmd->args_list[idx], argv[idx]) != 0) {
6776
printf("Test failed: Argument index %02u, value \"%s\" does not match actual argument value \"%s\"\r\n",

0 commit comments

Comments
 (0)