diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_common.c | 44 | ||||
-rw-r--r-- | tests/test_common.h | 6 | ||||
-rw-r--r-- | tests/testsuite.c | 4 |
3 files changed, 53 insertions, 1 deletions
diff --git a/tests/test_common.c b/tests/test_common.c index 0c4530a0..980f2198 100644 --- a/tests/test_common.c +++ b/tests/test_common.c @@ -587,3 +587,47 @@ void utf8_display_len_all_wide(void **state) assert_int_equal(8, result); } +void strip_quotes_does_nothing_when_no_quoted(void **state) +{ + char *input = "/cmd test string"; + + char *result = strip_arg_quotes(input); + + assert_string_equal("/cmd test string", result); + + free(result); +} + +void strip_quotes_strips_first(void **state) +{ + char *input = "/cmd \"test string"; + + char *result = strip_arg_quotes(input); + + assert_string_equal("/cmd test string", result); + + free(result); +} + +void strip_quotes_strips_last(void **state) +{ + char *input = "/cmd test string\""; + + char *result = strip_arg_quotes(input); + + assert_string_equal("/cmd test string", result); + + free(result); +} + +void strip_quotes_strips_both(void **state) +{ + char *input = "/cmd \"test string\""; + + char *result = strip_arg_quotes(input); + + assert_string_equal("/cmd test string", result); + + free(result); +} + diff --git a/tests/test_common.h b/tests/test_common.h index 1866e73d..b4b98e5a 100644 --- a/tests/test_common.h +++ b/tests/test_common.h @@ -51,4 +51,8 @@ void utf8_display_len_1_non_wide(void **state); void utf8_display_len_1_wide(void **state); void utf8_display_len_non_wide(void **state); void utf8_display_len_wide(void **state); -void utf8_display_len_all_wide(void **state); \ No newline at end of file +void utf8_display_len_all_wide(void **state); +void strip_quotes_does_nothing_when_no_quoted(void **state); +void strip_quotes_strips_first(void **state); +void strip_quotes_strips_last(void **state); +void strip_quotes_strips_both(void **state); diff --git a/tests/testsuite.c b/tests/testsuite.c index 92abee4b..0c6a4402 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -90,6 +90,10 @@ int main(int argc, char* argv[]) { unit_test(utf8_display_len_non_wide), unit_test(utf8_display_len_wide), unit_test(utf8_display_len_all_wide), + unit_test(strip_quotes_does_nothing_when_no_quoted), + unit_test(strip_quotes_strips_first), + unit_test(strip_quotes_strips_last), + unit_test(strip_quotes_strips_both), unit_test(clear_empty), unit_test(reset_after_create), |