changeset 2404:695798a54e5e

package hunspell: create test files when required
author Tony Theodore <tonyt@logyst.com>
date Sun, 15 Apr 2012 22:13:45 +1000
parents f30f0ad9cc06
children 7f4703a75221
files src/hunspell-test.aff src/hunspell-test.cxx src/hunspell-test.dic src/hunspell.mk
diffstat 4 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/hunspell-test.aff	Sun Apr 15 03:37:29 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-# A basic .aff for a raw wordlist, created through wordlist2hunspell
-SET UTF-8
-TRY loredWH
--- a/src/hunspell-test.cxx	Sun Apr 15 03:37:29 2012 -0700
+++ b/src/hunspell-test.cxx	Sun Apr 15 22:13:45 2012 +1000
@@ -1,13 +1,25 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
 #include <iostream>
+#include <fstream>
 #include <hunspell.hxx>
 
 int main(int argc, char *argv[])
 {
-    Hunspell h("hunspell-test.aff", "hunspell-test.dic");
-
     (void)argc;
     (void)argv;
 
+    std::ofstream dic ("hunspell-test.dic");
+    dic << "2\nHello\nWorld";
+    dic.close();
+    std::ofstream aff ("hunspell-test.aff");
+    aff << "SET UTF-8\nTRY loredWH\nMAXDIFF 1";
+    aff.close();    
+    Hunspell h("hunspell-test.aff", "hunspell-test.dic");
+
     if (h.spell("Hello") == 0)
     {
         std::cerr << "Error: hunspell marked correct word as wrong" << std::endl;
@@ -17,5 +29,9 @@
         std::cerr << "Error: hunspell marked wrong word as correct" << std::endl;
     }
     
+    char ** result;
+    int n = h.suggest(&result, "ell");
+    for (int i = 0; i < n; i++) std::cout << result[i];
+    
     return 0;
 }
--- a/src/hunspell-test.dic	Sun Apr 15 03:37:29 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-2
-Hello
-World
--- a/src/hunspell.mk	Sun Apr 15 03:37:29 2012 -0700
+++ b/src/hunspell.mk	Sun Apr 15 22:13:45 2012 +1000
@@ -33,6 +33,4 @@
         -W -Wall -Werror -ansi -pedantic \
         '$(2).cxx' -o '$(PREFIX)/$(TARGET)/bin/test-hunspell.exe' \
         `'$(TARGET)-pkg-config' hunspell --cflags --libs`
-    # Install dummy dictionary needed by the test program
-    $(INSTALL) -m644 -t '$(PREFIX)/$(TARGET)/bin' '$(TOP_DIR)/src/hunspell-test.aff' '$(TOP_DIR)/src/hunspell-test.dic'
 endef