diff options
Diffstat (limited to 'src/uci/command.c')
| -rw-r--r-- | src/uci/command.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/uci/command.c b/src/uci/command.c index c64fee2..583b887 100644 --- a/src/uci/command.c +++ b/src/uci/command.c @@ -101,25 +101,42 @@ bool test_uci_cmd_t() { uci_cmd_append_arg(&cmd, "arg2"); uci_cmd_append_arg(&cmd, "arg3"); - if (strncmp(cmd.root, "root", MAX_TOKEN_SIZE) != 0) return false; - if (strncmp(uci_cmd_get_arg(cmd, 0), "arg1", MAX_TOKEN_SIZE) != 0) + if (strncmp(cmd.root, "root", MAX_TOKEN_SIZE) != 0) { + uci_cmd_deinit(cmd); return false; - if (strncmp(uci_cmd_get_arg(cmd, 1), "arg2", MAX_TOKEN_SIZE) != 0) + } + if (strncmp(uci_cmd_get_arg(cmd, 0), "arg1", MAX_TOKEN_SIZE) != 0) { + uci_cmd_deinit(cmd); return false; - if (strncmp(uci_cmd_get_arg(cmd, 2), "arg3", MAX_TOKEN_SIZE) != 0) + } + if (strncmp(uci_cmd_get_arg(cmd, 1), "arg2", MAX_TOKEN_SIZE) != 0) { + uci_cmd_deinit(cmd); return false; + } + if (strncmp(uci_cmd_get_arg(cmd, 2), "arg3", MAX_TOKEN_SIZE) != 0) { + uci_cmd_deinit(cmd); + return false; + } + uci_cmd_deinit(cmd); return true; } bool test_invalid_cmd_uci_cmd_t() { - uci_cmd_t cmd = uci_cmd_t_init(); + uci_cmd_t cmd = uci_cmd_init(); + uci_cmd_add(&cmd, "john"); uci_cmd_add(&cmd, "debug"); uci_cmd_add(&cmd, "on"); - if (strncmp(cmd.root, "debug", MAX_TOKEN_SIZE) != 0) return false; - if (strncmp(uci_cmd_t_get_arg(cmd, 0), "on", MAX_TOKEN_SIZE) != 0) + if (strncmp(cmd.root, "debug", MAX_TOKEN_SIZE) != 0) { + uci_cmd_deinit(cmd); return false; + } + if (strncmp(uci_cmd_get_arg(cmd, 0), "on", MAX_TOKEN_SIZE) != 0) { + uci_cmd_deinit(cmd); + return false; + } + uci_cmd_deinit(cmd); return true; } #endif |
