about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-08 20:59:51 +0000
committerJames Booth <boothj5@gmail.com>2015-02-08 20:59:51 +0000
commit44c5b34a710f7c90b455ec92146530f95e25ab90 (patch)
tree4c739d224d6d67fec00c578707a062a77bf4fd19 /tests
parent236e508cd88f0f22688d8d9b5d5d52d8870b04ec (diff)
downloadprofani-tty-44c5b34a710f7c90b455ec92146530f95e25ab90.tar.gz
Moved quote stripper to common, added tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_common.c44
-rw-r--r--tests/test_common.h6
-rw-r--r--tests/testsuite.c4
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 cf511c59..ddfb45cd 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -91,6 +91,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),