aboutsummaryrefslogtreecommitdiff
path: root/StemmerRu/stemmer_test.go
blob: 018c6e38a60426abf1f48438b1e07219f0ac82c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)
		}
	}
}