Ruby tests were a nice way to start, and it was nice to borrow some from
selecta. However, it's going to be much easier to write tests in the
same language as the implementation.
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,22 +0,0 @@ |
| 1 |
-#include <stdlib.h> |
|
| 2 |
-#include <stdio.h> |
|
| 3 |
- |
|
| 4 |
-#include "fzy.h" |
|
| 5 |
-double match(const char *needle, const char *haystack); |
|
| 6 |
- |
|
| 7 |
-void usage(const char *argv0){
|
|
| 8 |
- fprintf(stderr, "USAGE: %s QUERY CANDIDATE\n", argv0); |
|
| 9 |
-} |
|
| 10 |
- |
|
| 11 |
-int main(int argc, char *argv[]){
|
|
| 12 |
- if(argc != 3){
|
|
| 13 |
- usage(argv[0]); |
|
| 14 |
- } |
|
| 15 |
- |
|
| 16 |
- if(has_match(argv[1], argv[2])){
|
|
| 17 |
- double result = match(argv[1], argv[2]); |
|
| 18 |
- printf("%f\n", result);
|
|
| 19 |
- } |
|
| 20 |
- |
|
| 21 |
- return 0; |
|
| 22 |
-} |
| ... | ... |
@@ -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 |
} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,20 @@ |
| 1 |
+#include <stdlib.h> |
|
| 2 |
+#include <stdio.h> |
|
| 3 |
+ |
|
| 4 |
+/* from match.c */ |
|
| 5 |
+double match(const char *needle, const char *haystack); |
|
| 6 |
+ |
|
| 7 |
+void usage(const char *argv0){
|
|
| 8 |
+ fprintf(stderr, "USAGE: %s QUERY CANDIDATE\n", argv0); |
|
| 9 |
+} |
|
| 10 |
+ |
|
| 11 |
+int main(int argc, char *argv[]){
|
|
| 12 |
+ if(argc != 3){
|
|
| 13 |
+ usage(argv[0]); |
|
| 14 |
+ } |
|
| 15 |
+ |
|
| 16 |
+ double result = match(argv[1], argv[2]); |
|
| 17 |
+ printf("%f\n", result);
|
|
| 18 |
+ |
|
| 19 |
+ return 0; |
|
| 20 |
+} |