Browse code

Update tests

John Hawthorn authored on 27/07/2014 02:22:19
Showing 2 changed files

... ...
@@ -4,11 +4,12 @@ require "minitest/autorun"
4 4
 describe "score" do
5 5
   def score(candidate, query)
6 6
     # FIXME: should escape this properly
7
-    `./testscore '#{query}' '#{candidate}'`.to_f
7
+    ret = `./testscore '#{query}' '#{candidate}'`
8
+    ret.to_f unless ret.empty?
8 9
   end
9 10
 
10 11
   def assert_unmatched(candidate, query)
11
-    assert_equal -1, score(candidate, query)
12
+    assert_equal nil, score(candidate, query)
12 13
   end
13 14
 
14 15
   def assert_matched(candidate, query)
... ...
@@ -1,7 +1,7 @@
1 1
 #include <stdlib.h>
2 2
 #include <stdio.h>
3 3
 
4
-/* from match.c */
4
+#include "fzy.h"
5 5
 double match(const char *needle, const char *haystack);
6 6
 
7 7
 void usage(const char *argv0){
... ...
@@ -13,8 +13,10 @@ int main(int argc, char *argv[]){
13 13
 		usage(argv[0]);
14 14
 	}
15 15
 
16
-	double result = match(argv[1], argv[2]);
17
-	printf("%f\n", result);
16
+	if(has_match(argv[1], argv[2])){
17
+		double result = match(argv[1], argv[2]);
18
+		printf("%f\n", result);
19
+	}
18 20
 
19 21
 	return 0;
20 22
 }