File: | build-analysis/../tests/client/t_command_trie.c |
Warning: | line 182, column 2 Access to field 'callback' results in a dereference of a null pointer (loaded from variable 'action') |
1 | /* XMMS2 - X Music Multiplexer System | |||||||
2 | * Copyright (C) 2003-2017 XMMS2 Team | |||||||
3 | * | |||||||
4 | * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!! | |||||||
5 | * | |||||||
6 | * This library is free software; you can redistribute it and/or | |||||||
7 | * modify it under the terms of the GNU Lesser General Public | |||||||
8 | * License as published by the Free Software Foundation; either | |||||||
9 | * version 2.1 of the License, or (at your option) any later version. | |||||||
10 | * | |||||||
11 | * This library is distributed in the hope that it will be useful, | |||||||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||||
14 | * Lesser General Public License for more details. | |||||||
15 | */ | |||||||
16 | ||||||||
17 | /* Wanted behaviour (no auto-complete): | |||||||
18 | * x<TAB> => | |||||||
19 | * <TAB> => [] / add, clear, pause, play, playlist, ... | |||||||
20 | * <TAB> => [ ] / add, clear, pause, play, playlist, ... | |||||||
21 | * a<TAB> => [add ] | |||||||
22 | * p<TAB> => [p] / pause, play, playlist, etc | |||||||
23 | * pa<TAB> => [pause] | |||||||
24 | * pla<TAB> => [play] / play, playlist | |||||||
25 | * pla <TAB> => [pla ] | |||||||
26 | * play<TAB> => [play] / play, playlist | |||||||
27 | * playl<TAB> => [playlist ] | |||||||
28 | * playlist<TAB> => [playlist ] | |||||||
29 | * playlist <TAB> => [playlist ] / clear, config, list, sort, ... | |||||||
30 | playlist <TAB> => [playlist ] / clear, config, list, sort, ... | |||||||
31 | FIXME: ^^^ FAILS currently, need deeper fix in command_trie.c I think | |||||||
32 | * playlist c<TAB> => [playlist c] / clear, config | |||||||
33 | * playlist clear<TAB> => [playlist clear ] | |||||||
34 | * playlist clear <TAB> => [playlist clear ] / <args> | |||||||
35 | playlist x<TAB> => [playlist x] | |||||||
36 | * add <TAB> => [add ] / <args> | |||||||
37 | * play <TAB> => [play ] / <args> | |||||||
38 | * play more<TAB> => [play more] / <args> | |||||||
39 | * play more <TAB> => [play more ] / <args> | |||||||
40 | */ | |||||||
41 | ||||||||
42 | #include "xcu.h" | |||||||
43 | ||||||||
44 | #include <stdio.h> | |||||||
45 | ||||||||
46 | #include <glib.h> | |||||||
47 | ||||||||
48 | #include <command_trie.h> | |||||||
49 | #include <xmmsc/xmmsc_strlist.h> | |||||||
50 | ||||||||
51 | static command_trie_t *trie; | |||||||
52 | ||||||||
53 | static gboolean | |||||||
54 | cmd_dummy (void *ctx, command_t *cmd) | |||||||
55 | { | |||||||
56 | return FALSE(0); | |||||||
57 | } | |||||||
58 | ||||||||
59 | SETUP (command_trie)static int __testsuite_setup (void); static int __testsuite_cleanup (void); static int __testsuite_setup (void) { | |||||||
60 | gint i; | |||||||
61 | ||||||||
62 | trie = command_trie_alloc (); | |||||||
63 | ||||||||
64 | const gchar *names[] = { | |||||||
65 | "play", "pause", "stop", | |||||||
66 | "playlist list", "playlist shuffle", "playlist sort" | |||||||
67 | }; | |||||||
68 | ||||||||
69 | for (i = 0; i < G_N_ELEMENTS (names)(sizeof (names) / sizeof ((names)[0])); i++) { | |||||||
70 | command_action_t *action = command_action_alloc (); | |||||||
71 | command_action_fill (action, names[i], cmd_dummy, | |||||||
72 | COMMAND_REQ_CONNECTION, | |||||||
73 | NULL((void*)0), NULL((void*)0), names[i]); | |||||||
74 | command_trie_insert (trie, action); | |||||||
75 | } | |||||||
76 | ||||||||
77 | return 0; | |||||||
78 | } | |||||||
79 | ||||||||
80 | CLEANUP ()static int __testsuite_cleanup (void) { | |||||||
81 | command_trie_free (trie); | |||||||
82 | trie = NULL((void*)0); | |||||||
83 | return 0; | |||||||
84 | } | |||||||
85 | ||||||||
86 | CASE (test_match_complete)static void __testcase_test_match_complete (void); void __testcase_wrapper_test_match_complete (void); void __testcase_wrapper_test_match_complete (void) { if (xcu_pre_case ("test_match_complete")) { __testsuite_setup (); __testcase_test_match_complete (); __testsuite_cleanup ( ); xcu_post_case ("test_match_complete"); } } static void __testcase_test_match_complete (void) | |||||||
87 | { | |||||||
88 | command_action_t *action = NULL((void*)0); | |||||||
89 | GList *suffixes = NULL((void*)0); | |||||||
90 | ||||||||
91 | gboolean auto_complete = FALSE(0); | |||||||
92 | ||||||||
93 | gchar **params = xmms_vargs_to_strlist ("playlist", "s", NULL((void*)0)); | |||||||
94 | ||||||||
95 | gchar **argv = params; | |||||||
96 | gint argc = xmms_strlist_len (argv); | |||||||
97 | ||||||||
98 | command_trie_match_type_t result = command_trie_find (trie, &argv, &argc, | |||||||
99 | auto_complete, | |||||||
100 | &action, &suffixes); | |||||||
101 | ||||||||
102 | CU_ASSERT_EQUAL (COMMAND_TRIE_MATCH_NONE, result){ CU_assertImplementation(((COMMAND_TRIE_MATCH_NONE) == (result )), 102, ("CU_ASSERT_EQUAL(" "COMMAND_TRIE_MATCH_NONE" "," "result" ")"), "../tests/client/t_command_trie.c", "", 0); }; | |||||||
103 | CU_ASSERT_STRING_EQUAL ("huffle", suffixes->data){ CU_assertImplementation(!(strcmp((const char*)("huffle"), ( const char*)(suffixes->data))), 103, ("CU_ASSERT_STRING_EQUAL(" "\"huffle\"" "," "suffixes->data" ")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
104 | CU_ASSERT_STRING_EQUAL ("ort", suffixes->next->data){ CU_assertImplementation(!(strcmp((const char*)("ort"), (const char*)(suffixes->next->data))), 104, ("CU_ASSERT_STRING_EQUAL(" "\"ort\"" "," "suffixes->next->data" ")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
105 | CU_ASSERT_PTR_NULL (suffixes->next->next){ CU_assertImplementation((((void*)0) == (void*)(suffixes-> next->next)), 105, ("CU_ASSERT_PTR_NULL(" "suffixes->next->next" ")"), "../tests/client/t_command_trie.c", "", 0); }; | |||||||
106 | CU_ASSERT_PTR_NULL (action){ CU_assertImplementation((((void*)0) == (void*)(action)), 106 , ("CU_ASSERT_PTR_NULL(" "action"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
107 | ||||||||
108 | g_list_free_full (suffixes, g_free); | |||||||
109 | xmms_strlist_destroy (params); | |||||||
110 | } | |||||||
111 | ||||||||
112 | CASE (test_match_auto_unique_complete)static void __testcase_test_match_auto_unique_complete (void) ; void __testcase_wrapper_test_match_auto_unique_complete (void ); void __testcase_wrapper_test_match_auto_unique_complete (void ) { if (xcu_pre_case ("test_match_auto_unique_complete")) { __testsuite_setup (); __testcase_test_match_auto_unique_complete (); __testsuite_cleanup (); xcu_post_case ("test_match_auto_unique_complete"); } } static void __testcase_test_match_auto_unique_complete (void) | |||||||
113 | { | |||||||
114 | command_action_t *action = NULL((void*)0); | |||||||
115 | GList *suffixes = NULL((void*)0); | |||||||
116 | ||||||||
117 | gboolean auto_complete = TRUE(!(0)); | |||||||
118 | ||||||||
119 | gchar **params = xmms_vargs_to_strlist ("playlist", "shuff", NULL((void*)0)); | |||||||
120 | ||||||||
121 | gchar **argv = params; | |||||||
122 | gint argc = xmms_strlist_len (argv); | |||||||
123 | ||||||||
124 | command_trie_match_type_t result = command_trie_find (trie, &argv, &argc, | |||||||
125 | auto_complete, | |||||||
126 | &action, &suffixes); | |||||||
127 | ||||||||
128 | CU_ASSERT_EQUAL (COMMAND_TRIE_MATCH_ACTION, result){ CU_assertImplementation(((COMMAND_TRIE_MATCH_ACTION) == (result )), 128, ("CU_ASSERT_EQUAL(" "COMMAND_TRIE_MATCH_ACTION" "," "result" ")"), "../tests/client/t_command_trie.c", "", 0); }; | |||||||
129 | CU_ASSERT_STRING_EQUAL ("le", suffixes->data){ CU_assertImplementation(!(strcmp((const char*)("le"), (const char*)(suffixes->data))), 129, ("CU_ASSERT_STRING_EQUAL(" "\"le\"" "," "suffixes->data" ")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
130 | CU_ASSERT_PTR_NULL (suffixes->next){ CU_assertImplementation((((void*)0) == (void*)(suffixes-> next)), 130, ("CU_ASSERT_PTR_NULL(" "suffixes->next"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
131 | CU_ASSERT_PTR_NOT_NULL (action){ CU_assertImplementation((((void*)0) != (void*)(action)), 131 , ("CU_ASSERT_PTR_NOT_NULL(" "action"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
132 | CU_ASSERT_PTR_NOT_NULL (action->callback){ CU_assertImplementation((((void*)0) != (void*)(action->callback )), 132, ("CU_ASSERT_PTR_NOT_NULL(" "action->callback"")") , "../tests/client/t_command_trie.c", "", 0); }; | |||||||
133 | ||||||||
134 | g_list_free_full (suffixes, g_free); | |||||||
135 | xmms_strlist_destroy (params); | |||||||
136 | } | |||||||
137 | ||||||||
138 | CASE (test_match_exact_action)static void __testcase_test_match_exact_action (void); void __testcase_wrapper_test_match_exact_action (void); void __testcase_wrapper_test_match_exact_action (void ) { if (xcu_pre_case ("test_match_exact_action")) { __testsuite_setup (); __testcase_test_match_exact_action (); __testsuite_cleanup (); xcu_post_case ("test_match_exact_action"); } } static void __testcase_test_match_exact_action (void) | |||||||
139 | { | |||||||
140 | command_action_t *action = NULL((void*)0); | |||||||
141 | GList *suffixes = NULL((void*)0); | |||||||
142 | ||||||||
143 | gboolean auto_complete = FALSE(0); | |||||||
144 | ||||||||
145 | gchar **params = xmms_vargs_to_strlist ("playlist", "shuffle", NULL((void*)0)); | |||||||
146 | ||||||||
147 | gchar **argv = params; | |||||||
148 | gint argc = xmms_strlist_len (argv); | |||||||
149 | ||||||||
150 | command_trie_match_type_t result = command_trie_find (trie, &argv, &argc, | |||||||
151 | auto_complete, | |||||||
152 | &action, &suffixes); | |||||||
153 | ||||||||
154 | CU_ASSERT_EQUAL (COMMAND_TRIE_MATCH_ACTION, result){ CU_assertImplementation(((COMMAND_TRIE_MATCH_ACTION) == (result )), 154, ("CU_ASSERT_EQUAL(" "COMMAND_TRIE_MATCH_ACTION" "," "result" ")"), "../tests/client/t_command_trie.c", "", 0); }; | |||||||
155 | CU_ASSERT_PTR_NULL (suffixes){ CU_assertImplementation((((void*)0) == (void*)(suffixes)), 155 , ("CU_ASSERT_PTR_NULL(" "suffixes"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
156 | CU_ASSERT_PTR_NOT_NULL (action){ CU_assertImplementation((((void*)0) != (void*)(action)), 156 , ("CU_ASSERT_PTR_NOT_NULL(" "action"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
157 | CU_ASSERT_PTR_NOT_NULL (action->callback){ CU_assertImplementation((((void*)0) != (void*)(action->callback )), 157, ("CU_ASSERT_PTR_NOT_NULL(" "action->callback"")") , "../tests/client/t_command_trie.c", "", 0); }; | |||||||
158 | ||||||||
159 | xmms_strlist_destroy (params); | |||||||
160 | } | |||||||
161 | ||||||||
162 | ||||||||
163 | CASE (test_match_exact_subtrie)static void __testcase_test_match_exact_subtrie (void); void __testcase_wrapper_test_match_exact_subtrie (void); void __testcase_wrapper_test_match_exact_subtrie (void ) { if (xcu_pre_case ("test_match_exact_subtrie")) { __testsuite_setup (); __testcase_test_match_exact_subtrie (); __testsuite_cleanup (); xcu_post_case ("test_match_exact_subtrie"); } } static void __testcase_test_match_exact_subtrie (void) | |||||||
| ||||||||
164 | { | |||||||
165 | command_action_t *action = NULL((void*)0); | |||||||
166 | GList *suffixes = NULL((void*)0); | |||||||
167 | ||||||||
168 | gboolean auto_complete = FALSE(0); | |||||||
169 | ||||||||
170 | gchar **params = xmms_vargs_to_strlist ("playlist", NULL((void*)0)); | |||||||
171 | ||||||||
172 | gchar **argv = params; | |||||||
173 | gint argc = xmms_strlist_len (argv); | |||||||
174 | ||||||||
175 | command_trie_match_type_t result = command_trie_find (trie, &argv, &argc, | |||||||
176 | auto_complete, | |||||||
177 | &action, &suffixes); | |||||||
178 | ||||||||
179 | CU_ASSERT_EQUAL (COMMAND_TRIE_MATCH_SUBTRIE, result){ CU_assertImplementation(((COMMAND_TRIE_MATCH_SUBTRIE) == (result )), 179, ("CU_ASSERT_EQUAL(" "COMMAND_TRIE_MATCH_SUBTRIE" "," "result" ")"), "../tests/client/t_command_trie.c", "", 0); }; | |||||||
180 | CU_ASSERT_PTR_NULL (suffixes){ CU_assertImplementation((((void*)0) == (void*)(suffixes)), 180 , ("CU_ASSERT_PTR_NULL(" "suffixes"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
181 | CU_ASSERT_PTR_NOT_NULL (action){ CU_assertImplementation((((void*)0) != (void*)(action)), 181 , ("CU_ASSERT_PTR_NOT_NULL(" "action"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
182 | CU_ASSERT_PTR_NULL (action->callback){ CU_assertImplementation((((void*)0) == (void*)(action->callback )), 182, ("CU_ASSERT_PTR_NULL(" "action->callback"")"), "../tests/client/t_command_trie.c" , "", 0); }; | |||||||
| ||||||||
183 | ||||||||
184 | xmms_strlist_destroy (params); | |||||||
185 | } |