about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-11-18 02:40:49 +0000
committerJames Booth <boothj5@gmail.com>2012-11-18 02:40:49 +0000
commit78dd79f6a03827cd9d483a24b122b066735c3606 (patch)
tree98d78bc1f2c60ce4358696882b020c9bc5cc4260 /tests
parent0cec188eb5445283e5f1442439a83c36c071c678 (diff)
downloadprofani-tty-78dd79f6a03827cd9d483a24b122b066735c3606.tar.gz
Commands now use parser function to handle parameters
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parser.c66
1 files changed, 25 insertions, 41 deletions
diff --git a/tests/test_parser.c b/tests/test_parser.c
index 9a692edc..a829f37e 100644
--- a/tests/test_parser.c
+++ b/tests/test_parser.c
@@ -7,8 +7,7 @@ void
 parse_null_returns_null(void)
 {
     char *inp = NULL;
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 2, &num);
+    gchar **result = parse_args(inp, 1, 2);
 
     assert_is_null(result);
     g_strfreev(result);
@@ -18,8 +17,7 @@ void
 parse_empty_returns_null(void)
 {
     char *inp = "";
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 2, &num);
+    gchar **result = parse_args(inp, 1, 2);
 
     assert_is_null(result);
     g_strfreev(result);
@@ -29,8 +27,7 @@ void
 parse_space_returns_null(void)
 {
     char *inp = "   ";
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 2, &num);
+    gchar **result = parse_args(inp, 1, 2);
 
     assert_is_null(result);
     g_strfreev(result);
@@ -40,8 +37,7 @@ void
 parse_cmd_no_args_returns_null(void)
 {
     char *inp = "/cmd";
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 2, &num);
+    gchar **result = parse_args(inp, 1, 2);
 
     assert_is_null(result);
     g_strfreev(result);
@@ -51,8 +47,7 @@ void
 parse_cmd_with_space_returns_null(void)
 {
     char *inp = "/cmd   ";
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 2, &num);
+    gchar **result = parse_args(inp, 1, 2);
 
     assert_is_null(result);
     g_strfreev(result);
@@ -62,8 +57,7 @@ void
 parse_cmd_with_too_few_returns_null(void)
 {
     char *inp = "/cmd arg1";
-    int num = 0;
-    gchar **result = parse_args(inp, 2, 3, &num);
+    gchar **result = parse_args(inp, 2, 3);
 
     assert_is_null(result);
     g_strfreev(result);
@@ -73,8 +67,7 @@ void
 parse_cmd_with_too_many_returns_null(void)
 {
     char *inp = "/cmd arg1 arg2 arg3 arg4";
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 3, &num);
+    gchar **result = parse_args(inp, 1, 3);
 
     assert_is_null(result);
     g_strfreev(result);
@@ -84,10 +77,9 @@ void
 parse_cmd_one_arg(void)
 {
     char *inp = "/cmd arg1";
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 2, &num);
+    gchar **result = parse_args(inp, 1, 2);
 
-    assert_int_equals(1, num);
+    assert_int_equals(1, g_strv_length(result));
     assert_string_equals("arg1", result[0]);
     g_strfreev(result);
 }
@@ -96,10 +88,9 @@ void
 parse_cmd_two_args(void)
 {
     char *inp = "/cmd arg1 arg2";
-    int num = 0;
-    gchar **result = parse_args(inp, 1, 2, &num);
+    gchar **result = parse_args(inp, 1, 2);
 
-    assert_int_equals(2, num);
+    assert_int_equals(2, g_strv_length(result));
     assert_string_equals("arg1", result[0]);
     assert_string_equals("arg2", result[1]);
     g_strfreev(result);
@@ -109,10 +100,9 @@ void
 parse_cmd_three_args(void)
 {
     char *inp = "/cmd arg1 arg2 arg3";
-    int num = 0;
-    gchar **result = parse_args(inp, 3, 3, &num);
+    gchar **result = parse_args(inp, 3, 3);
 
-    assert_int_equals(3, num);
+    assert_int_equals(3, g_strv_length(result));
     assert_string_equals("arg1", result[0]);
     assert_string_equals("arg2", result[1]);
     assert_string_equals("arg3", result[2]);
@@ -123,10 +113,9 @@ void
 parse_cmd_three_args_with_spaces(void)
 {
     char *inp = "  /cmd    arg1  arg2     arg3 ";
-    int num = 0;
-    gchar **result = parse_args(inp, 3, 3, &num);
+    gchar **result = parse_args(inp, 3, 3);
 
-    assert_int_equals(3, num);
+    assert_int_equals(3, g_strv_length(result));
     assert_string_equals("arg1", result[0]);
     assert_string_equals("arg2", result[1]);
     assert_string_equals("arg3", result[2]);
@@ -137,10 +126,9 @@ void
 parse_cmd_with_freetext(void)
 {
     char *inp = "/cmd this is some free text";
-    int num = 0;
-    gchar **result = parse_args_with_freetext(inp, 1, 1, &num);
+    gchar **result = parse_args_with_freetext(inp, 1, 1);
 
-    assert_int_equals(1, num);
+    assert_int_equals(1, g_strv_length(result));
     assert_string_equals("this is some free text", result[0]);
     g_strfreev(result);
 }
@@ -149,10 +137,9 @@ void
 parse_cmd_one_arg_with_freetext(void)
 {
     char *inp = "/cmd arg1 this is some free text";
-    int num = 0;
-    gchar **result = parse_args_with_freetext(inp, 1, 2, &num);
+    gchar **result = parse_args_with_freetext(inp, 1, 2);
 
-    assert_int_equals(2, num);
+    assert_int_equals(2, g_strv_length(result));
     assert_string_equals("arg1", result[0]);
     assert_string_equals("this is some free text", result[1]);
     g_strfreev(result);
@@ -162,10 +149,9 @@ void
 parse_cmd_two_args_with_freetext(void)
 {
     char *inp = "/cmd arg1 arg2 this is some free text";
-    int num = 0;
-    gchar **result = parse_args_with_freetext(inp, 1, 3, &num);
+    gchar **result = parse_args_with_freetext(inp, 1, 3);
 
-    assert_int_equals(3, num);
+    assert_int_equals(3, g_strv_length(result));
     assert_string_equals("arg1", result[0]);
     assert_string_equals("arg2", result[1]);
     assert_string_equals("this is some free text", result[2]);
@@ -176,10 +162,9 @@ void
 parse_cmd_min_zero(void)
 {
     char *inp = "/cmd";
-    int num = 0;
-    gchar **result = parse_args(inp, 0, 2, &num);
+    gchar **result = parse_args(inp, 0, 2);
 
-    assert_int_equals(0, num);
+    assert_int_equals(0, g_strv_length(result));
     assert_is_null(result[0]);
     g_strfreev(result);
 }
@@ -188,10 +173,9 @@ void
 parse_cmd_min_zero_with_freetext(void)
 {
     char *inp = "/cmd";
-    int num = 0;
-    gchar **result = parse_args_with_freetext(inp, 0, 2, &num);
+    gchar **result = parse_args_with_freetext(inp, 0, 2);
 
-    assert_int_equals(0, num);
+    assert_int_equals(0, g_strv_length(result));
     assert_is_null(result[0]);
     g_strfreev(result);
 }