aboutsummaryrefslogtreecommitdiff
path: root/StemmerRu/stemmer_test.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2018-05-10 03:00:52 +0300
committerAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2018-05-10 03:00:52 +0300
commit6796db17de2374cb3120287ebeb0b6a02d0b8089 (patch)
treef4055e43f8b5a107c838cb0ebd4be4cf6c8dcdf2 /StemmerRu/stemmer_test.go
Initial
Diffstat (limited to 'StemmerRu/stemmer_test.go')
-rw-r--r--StemmerRu/stemmer_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/StemmerRu/stemmer_test.go b/StemmerRu/stemmer_test.go
new file mode 100644
index 0000000..018c6e3
--- /dev/null
+++ b/StemmerRu/stemmer_test.go
@@ -0,0 +1,28 @@
+package StemmerRu
+
+import (
+ "testing"
+ "io/ioutil"
+ "encoding/json"
+ "path"
+)
+
+var testFile = path.Join(`..`, `tests.json`)
+
+func TestStemWord(t *testing.T) {
+ file, err := ioutil.ReadFile(testFile)
+ if err != nil {
+ t.Error("Can't open file", testFile)
+ }
+ tests := &map[string]string{}
+ err = json.Unmarshal(file, tests)
+ if err != nil {
+ t.Error("Can't parse json", err)
+ }
+ for source, expected := range *tests {
+ result := StemWord(source);
+ if expected != result {
+ t.Errorf(`Expected "%s" (source: %s) but got "%s"`, result, source, result)
+ }
+ }
+}