about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_autocomplete.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/tests/test_autocomplete.c b/tests/test_autocomplete.c
index b7d70e9b..77525035 100644
--- a/tests/test_autocomplete.c
+++ b/tests/test_autocomplete.c
@@ -39,9 +39,8 @@ static void get_after_create_returns_null(void)
 
 static void add_one_and_complete(void)
 {
-    char *item = strdup("Hello");
     Autocomplete ac = autocomplete_new();
-    autocomplete_add(ac, item);
+    autocomplete_add(ac, "Hello");
     char *result = autocomplete_complete(ac, "Hel");
 
     assert_string_equals("Hello", result);
@@ -51,11 +50,9 @@ static void add_one_and_complete(void)
 
 static void add_two_and_complete_returns_first(void)
 {
-    char *item1 = strdup("Hello");
-    char *item2 = strdup("Help");
     Autocomplete ac = autocomplete_new();
-    autocomplete_add(ac, item1);
-    autocomplete_add(ac, item2);
+    autocomplete_add(ac, "Hello");
+    autocomplete_add(ac, "Help");
     char *result = autocomplete_complete(ac, "Hel");
 
     assert_string_equals("Hello", result);
@@ -65,11 +62,9 @@ static void add_two_and_complete_returns_first(void)
 
 static void add_two_and_complete_returns_second(void)
 {
-    char *item1 = strdup("Hello");
-    char *item2 = strdup("Help");
     Autocomplete ac = autocomplete_new();
-    autocomplete_add(ac, item1);
-    autocomplete_add(ac, item2);
+    autocomplete_add(ac, "Hello");
+    autocomplete_add(ac, "Help");
     char *result1 = autocomplete_complete(ac, "Hel");
     char *result2 = autocomplete_complete(ac, result1);
 
@@ -80,11 +75,9 @@ static void add_two_and_complete_returns_second(void)
 
 static void add_two_adds_two(void)
 {
-    char *item1 = strdup("Hello");
-    char *item2 = strdup("Help");
     Autocomplete ac = autocomplete_new();
-    autocomplete_add(ac, item1);
-    autocomplete_add(ac, item2);
+    autocomplete_add(ac, "Hello");
+    autocomplete_add(ac, "Help");
     GSList *result = autocomplete_get_list(ac);
 
     assert_int_equals(2, g_slist_length(result));
@@ -94,11 +87,9 @@ static void add_two_adds_two(void)
 
 static void add_two_same_adds_one(void)
 {
-    char *item1 = strdup("Hello");
-    char *item2 = strdup("Hello");
     Autocomplete ac = autocomplete_new();
-    autocomplete_add(ac, item1);
-    autocomplete_add(ac, item2);
+    autocomplete_add(ac, "Hello");
+    autocomplete_add(ac, "Hello");
     GSList *result = autocomplete_get_list(ac);
 
     assert_int_equals(1, g_slist_length(result));
@@ -108,11 +99,9 @@ static void add_two_same_adds_one(void)
 
 static void add_two_same_updates(void)
 {
-    char *item1 = strdup("Hello");
-    char *item2 = strdup("Hello");
     Autocomplete ac = autocomplete_new();
-    autocomplete_add(ac, item1);
-    autocomplete_add(ac, item2);
+    autocomplete_add(ac, "Hello");
+    autocomplete_add(ac, "Hello");
     GSList *result = autocomplete_get_list(ac);
 
     GSList *first = g_slist_nth(result, 0);
@@ -126,9 +115,8 @@ static void add_two_same_updates(void)
 
 static void add_one_returns_true(void)
 {
-    char *item = strdup("Hello");
     Autocomplete ac = autocomplete_new();
-    int result = autocomplete_add(ac, item);
+    int result = autocomplete_add(ac, "Hello");
 
     assert_true(result);
 
@@ -137,11 +125,9 @@ static void add_one_returns_true(void)
 
 static void add_two_different_returns_true(void)
 {
-    char *item1 = strdup("Hello");
-    char *item2 = strdup("Hello there");
     Autocomplete ac = autocomplete_new();
-    int result1 = autocomplete_add(ac, item1);
-    int result2 = autocomplete_add(ac, item2);
+    int result1 = autocomplete_add(ac, "Hello");
+    int result2 = autocomplete_add(ac, "Hello there");
 
     assert_true(result1);
     assert_true(result2);
@@ -151,11 +137,9 @@ static void add_two_different_returns_true(void)
 
 static void add_two_same_returns_false(void)
 {
-    char *item1 = strdup("Hello");
-    char *item2 = strdup("Hello");
     Autocomplete ac = autocomplete_new();
-    int result1 = autocomplete_add(ac, item1);
-    int result2 = autocomplete_add(ac, item2);
+    int result1 = autocomplete_add(ac, "Hello");
+    int result2 = autocomplete_add(ac, "Hello");
 
     assert_true(result1);
     assert_false(result2);
py?h=v1.6.1&id=a66c4a26f79d71210422f7d977b892d5a700dae8'>a66c4a26 ^
f027adc0 ^
5c210a96 ^

3de15ddd ^

5c210a96 ^
fb275079 ^

5c210a96 ^
3d566884 ^
a1d7ed6e ^
3d566884 ^
f8e96a97 ^
465bff73 ^





f027adc0 ^
f8e96a97 ^

0b5c4cbe ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67