Merge lp:~ted/hud/lp1193700 into lp:hud/13.10

Proposed by Ted Gould
Status: Merged
Approved by: Ted Gould
Approved revision: 319
Merged at revision: 320
Proposed branch: lp:~ted/hud/lp1193700
Merge into: lp:hud/13.10
Diff against target: 71 lines (+30/-0)
2 files modified
src/token.c (+13/-0)
tests/test-distance.c (+17/-0)
To merge this branch: bzr merge lp:~ted/hud/lp1193700
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Pete Woods (community) Approve
Review via email: mp+183797@code.launchpad.net

Commit message

Handle searches that result in no tokens as NULL searches

Description of the change

Searching for "-" was apparently causing problems. Not sure why people were doing this, perhaps they were looking for the dash? ;-)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Weird. Unable to a DBus name. Trying again for that one. Seems odd.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/token.c'
2--- src/token.c 2013-06-03 03:15:56 +0000
3+++ src/token.c 2013-09-04 03:25:47 +0000
4@@ -272,6 +272,13 @@
5
6 array = g_ptr_array_new ();
7 hud_token_list_add_string_to_array (array, string);
8+
9+ if (array->len == 0)
10+ {
11+ g_ptr_array_free (array, TRUE);
12+ return NULL;
13+ }
14+
15 return hud_token_list_new_consume_array (array);
16 }
17
18@@ -291,6 +298,9 @@
19 {
20 gint i;
21
22+ if (list == NULL)
23+ return;
24+
25 for (i = 0; i < list->length; i++)
26 hud_token_free (list->tokens[i]);
27
28@@ -307,6 +317,9 @@
29 static guint d[32][32];
30 gint i, j;
31
32+ if (needle == NULL || haystack == NULL)
33+ return G_MAXUINT;
34+
35 if (needle->length > haystack->length)
36 return G_MAXUINT;
37
38
39=== modified file 'tests/test-distance.c'
40--- tests/test-distance.c 2013-06-03 03:27:33 +0000
41+++ tests/test-distance.c 2013-09-04 03:25:47 +0000
42@@ -240,6 +240,22 @@
43 calculate_distance ("save", (GStrv) save_as, NULL));
44 }
45
46+/* Checking to ensure that we can put separators in and don't screw things up */
47+static void
48+test_distance_separator_only (void)
49+{
50+ gchar * teststrings[] = {"One", "Two", NULL};
51+
52+ g_assert(calculate_distance("-", (GStrv) teststrings, NULL) != 0);
53+ g_assert(calculate_distance(">", (GStrv) teststrings, NULL) != 0);
54+ g_assert(calculate_distance(".", (GStrv) teststrings, NULL) != 0);
55+ g_assert(calculate_distance(" ", (GStrv) teststrings, NULL) != 0);
56+ g_assert(calculate_distance(" .->", (GStrv) teststrings, NULL) != 0);
57+ g_assert(calculate_distance("", (GStrv) teststrings, NULL) != 0);
58+
59+ return;
60+}
61+
62 /* Build the test suite */
63 static void
64 test_distance_suite (void)
65@@ -252,6 +268,7 @@
66 g_test_add_func ("/hud/distance/variety", test_distance_variety);
67 g_test_add_func ("/hud/distance/french_pref", test_distance_french_pref);
68 g_test_add_func ("/hud/distance/extra_terms", test_distance_extra_terms);
69+ g_test_add_func ("/hud/distance/separator_only",test_distance_separator_only);
70 return;
71 }
72

Subscribers

People subscribed via source and target branches