Upgrade server dependencies, manage them with govendor

This commit is contained in:
Ken-Håvard Lieng 2017-04-18 03:02:51 +02:00
parent ebee2746d6
commit 971278e7e5
1748 changed files with 196165 additions and 194500 deletions

View file

@ -1,57 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestContainsVowel(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected bool
}, 15)
tests[i].S = []rune("apple")
tests[i].Expected = true
i++
tests[i].S = []rune("f")
tests[i].Expected = false
i++
tests[i].S = []rune("a")
tests[i].Expected = true
i++
tests[i].S = []rune("e")
tests[i].Expected = true
i++
tests[i].S = []rune("i")
tests[i].Expected = true
i++
tests[i].S = []rune("o")
tests[i].Expected = true
i++
tests[i].S = []rune("u")
tests[i].Expected = true
i++
tests[i].S = []rune("y")
tests[i].Expected = false
i++
tests[i].S = []rune("cy")
tests[i].Expected = true
i++
for _, datum := range tests {
if actual := containsVowel(datum.S); actual != datum.Expected {
t.Errorf("Did NOT get what was expected for calling containsVowel() on [%s]. Expect [%t] but got [%t]", string(datum.S), datum.Expected, actual)
}
}
}

View file

@ -1,20 +0,0 @@
package porterstemmer
import (
"testing"
)
// Test for issue listed here:
// https://github.com/reiver/go-porterstemmer/issues/1
//
// StemString("ion") was causing runtime exception
func TestStemStringIon(t *testing.T) {
expected := "ion"
s := "ion"
actual := StemString(s)
if expected != actual {
t.Errorf("Input: [%s] -> Actual: [%s]. Expected: [%s]", s, actual, expected)
}
}

View file

@ -1,59 +0,0 @@
package porterstemmer
import (
"bytes"
"testing"
)
const maxFuzzLen = 6
// Test inputs of English characters less than maxFuzzLen
// Added to help diagnose https://github.com/reiver/go-porterstemmer/issues/4
func TestStemFuzz(t *testing.T) {
input := []byte{'a'}
for len(input) < maxFuzzLen {
// test input
panicked := false
func() {
defer func() { panicked = recover() != nil }()
StemString(string(input))
}()
if panicked {
t.Errorf("StemString panicked for input '%s'", input)
}
// if all z's extend
if allZs(input) {
input = bytes.Repeat([]byte{'a'}, len(input)+1)
} else {
// increment
input = incrementBytes(input)
}
}
}
func incrementBytes(in []byte) []byte {
rv := make([]byte, len(in))
copy(rv, in)
for i := len(rv) - 1; i >= 0; i-- {
if rv[i]+1 == '{' {
rv[i] = 'a'
continue
}
rv[i] = rv[i] + 1
break
}
return rv
}
func allZs(in []byte) bool {
for _, b := range in {
if b != 'z' {
return false
}
}
return true
}

View file

@ -1,42 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestHasDoubleConsonantSuffix(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected bool
}, 12)
tests[i].S = []rune("apple")
tests[i].Expected = false
i++
tests[i].S = []rune("hiss")
tests[i].Expected = true
i++
tests[i].S = []rune("fizz")
tests[i].Expected = true
i++
tests[i].S = []rune("fill")
tests[i].Expected = true
i++
tests[i].S = []rune("ahaa")
tests[i].Expected = false
i++
for _, datum := range tests {
if actual := hasRepeatDoubleConsonantSuffix(datum.S); actual != datum.Expected {
t.Errorf("Did NOT get what was expected for calling hasDoubleConsonantSuffix() on [%s]. Expect [%t] but got [%t]", string(datum.S), datum.Expected, actual)
}
}
}

View file

@ -1,432 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestHasSuffix(t *testing.T) {
tests := make([]struct {
S []rune
Suffix []rune
Expected bool
}, 82)
i := 0
tests[i].S = []rune("ran")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
tests[i].S = []rune("runner")
tests[i].Suffix = []rune("er")
tests[i].Expected = true
i++
tests[i].S = []rune("runnar")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
tests[i].S = []rune("runned")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
tests[i].S = []rune("runnre")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
// FIXME marty changed Expected
// to false here because it seems
// the contract does not support
// suffix of same length as input
// as this test implied
tests[i].S = []rune("er")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
tests[i].S = []rune("re")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
tests[i].S = []rune("ran")
tests[i].Suffix = []rune("ER")
tests[i].Expected = false
i++
tests[i].S = []rune("runner")
tests[i].Suffix = []rune("ER")
tests[i].Expected = false
i++
tests[i].S = []rune("runnar")
tests[i].Suffix = []rune("ER")
tests[i].Expected = false
i++
tests[i].S = []rune("runned")
tests[i].Suffix = []rune("ER")
tests[i].Expected = false
i++
tests[i].S = []rune("runnre")
tests[i].Suffix = []rune("ER")
tests[i].Expected = false
i++
tests[i].S = []rune("er")
tests[i].Suffix = []rune("ER")
tests[i].Expected = false
i++
tests[i].S = []rune("re")
tests[i].Suffix = []rune("ER")
tests[i].Expected = false
i++
tests[i].S = []rune("")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
tests[i].S = []rune("e")
tests[i].Suffix = []rune("er")
tests[i].Expected = false
i++
tests[i].S = []rune("caresses")
tests[i].Suffix = []rune("sses")
tests[i].Expected = true
i++
tests[i].S = []rune("ponies")
tests[i].Suffix = []rune("ies")
tests[i].Expected = true
i++
tests[i].S = []rune("caress")
tests[i].Suffix = []rune("ss")
tests[i].Expected = true
i++
tests[i].S = []rune("cats")
tests[i].Suffix = []rune("s")
tests[i].Expected = true
i++
tests[i].S = []rune("feed")
tests[i].Suffix = []rune("eed")
tests[i].Expected = true
i++
tests[i].S = []rune("agreed")
tests[i].Suffix = []rune("eed")
tests[i].Expected = true
i++
tests[i].S = []rune("plastered")
tests[i].Suffix = []rune("ed")
tests[i].Expected = true
i++
tests[i].S = []rune("bled")
tests[i].Suffix = []rune("ed")
tests[i].Expected = true
i++
tests[i].S = []rune("motoring")
tests[i].Suffix = []rune("ing")
tests[i].Expected = true
i++
tests[i].S = []rune("sing")
tests[i].Suffix = []rune("ing")
tests[i].Expected = true
i++
tests[i].S = []rune("conflat")
tests[i].Suffix = []rune("at")
tests[i].Expected = true
i++
tests[i].S = []rune("troubl")
tests[i].Suffix = []rune("bl")
tests[i].Expected = true
i++
tests[i].S = []rune("siz")
tests[i].Suffix = []rune("iz")
tests[i].Expected = true
i++
tests[i].S = []rune("happy")
tests[i].Suffix = []rune("y")
tests[i].Expected = true
i++
tests[i].S = []rune("sky")
tests[i].Suffix = []rune("y")
tests[i].Expected = true
i++
tests[i].S = []rune("relational")
tests[i].Suffix = []rune("ational")
tests[i].Expected = true
i++
tests[i].S = []rune("conditional")
tests[i].Suffix = []rune("tional")
tests[i].Expected = true
i++
tests[i].S = []rune("rational")
tests[i].Suffix = []rune("tional")
tests[i].Expected = true
i++
tests[i].S = []rune("valenci")
tests[i].Suffix = []rune("enci")
tests[i].Expected = true
i++
tests[i].S = []rune("hesitanci")
tests[i].Suffix = []rune("anci")
tests[i].Expected = true
i++
tests[i].S = []rune("digitizer")
tests[i].Suffix = []rune("izer")
tests[i].Expected = true
i++
tests[i].S = []rune("conformabli")
tests[i].Suffix = []rune("abli")
tests[i].Expected = true
i++
tests[i].S = []rune("radicalli")
tests[i].Suffix = []rune("alli")
tests[i].Expected = true
i++
tests[i].S = []rune("differentli")
tests[i].Suffix = []rune("entli")
tests[i].Expected = true
i++
tests[i].S = []rune("vileli")
tests[i].Suffix = []rune("eli")
tests[i].Expected = true
i++
tests[i].S = []rune("analogousli")
tests[i].Suffix = []rune("ousli")
tests[i].Expected = true
i++
tests[i].S = []rune("vietnamization")
tests[i].Suffix = []rune("ization")
tests[i].Expected = true
i++
tests[i].S = []rune("predication")
tests[i].Suffix = []rune("ation")
tests[i].Expected = true
i++
tests[i].S = []rune("operator")
tests[i].Suffix = []rune("ator")
tests[i].Expected = true
i++
tests[i].S = []rune("feudalism")
tests[i].Suffix = []rune("alism")
tests[i].Expected = true
i++
tests[i].S = []rune("decisiveness")
tests[i].Suffix = []rune("iveness")
tests[i].Expected = true
i++
tests[i].S = []rune("hopefulness")
tests[i].Suffix = []rune("fulness")
tests[i].Expected = true
i++
tests[i].S = []rune("callousness")
tests[i].Suffix = []rune("ousness")
tests[i].Expected = true
i++
tests[i].S = []rune("formaliti")
tests[i].Suffix = []rune("aliti")
tests[i].Expected = true
i++
tests[i].S = []rune("sensitiviti")
tests[i].Suffix = []rune("iviti")
tests[i].Expected = true
i++
tests[i].S = []rune("sensibiliti")
tests[i].Suffix = []rune("biliti")
tests[i].Expected = true
i++
tests[i].S = []rune("triplicate")
tests[i].Suffix = []rune("icate")
tests[i].Expected = true
i++
tests[i].S = []rune("formative")
tests[i].Suffix = []rune("ative")
tests[i].Expected = true
i++
tests[i].S = []rune("formalize")
tests[i].Suffix = []rune("alize")
tests[i].Expected = true
i++
tests[i].S = []rune("electriciti")
tests[i].Suffix = []rune("iciti")
tests[i].Expected = true
i++
tests[i].S = []rune("electrical")
tests[i].Suffix = []rune("ical")
tests[i].Expected = true
i++
tests[i].S = []rune("hopeful")
tests[i].Suffix = []rune("ful")
tests[i].Expected = true
i++
tests[i].S = []rune("goodness")
tests[i].Suffix = []rune("ness")
tests[i].Expected = true
i++
tests[i].S = []rune("revival")
tests[i].Suffix = []rune("al")
tests[i].Expected = true
i++
tests[i].S = []rune("allowance")
tests[i].Suffix = []rune("ance")
tests[i].Expected = true
i++
tests[i].S = []rune("inference")
tests[i].Suffix = []rune("ence")
tests[i].Expected = true
i++
tests[i].S = []rune("airliner")
tests[i].Suffix = []rune("er")
tests[i].Expected = true
i++
tests[i].S = []rune("gyroscopic")
tests[i].Suffix = []rune("ic")
tests[i].Expected = true
i++
tests[i].S = []rune("adjustable")
tests[i].Suffix = []rune("able")
tests[i].Expected = true
i++
tests[i].S = []rune("defensible")
tests[i].Suffix = []rune("ible")
tests[i].Expected = true
i++
tests[i].S = []rune("irritant")
tests[i].Suffix = []rune("ant")
tests[i].Expected = true
i++
tests[i].S = []rune("replacement")
tests[i].Suffix = []rune("ement")
tests[i].Expected = true
i++
tests[i].S = []rune("adjustment")
tests[i].Suffix = []rune("ment")
tests[i].Expected = true
i++
tests[i].S = []rune("dependent")
tests[i].Suffix = []rune("ent")
tests[i].Expected = true
i++
tests[i].S = []rune("adoption")
tests[i].Suffix = []rune("ion")
tests[i].Expected = true
i++
tests[i].S = []rune("homologou")
tests[i].Suffix = []rune("ou")
tests[i].Expected = true
i++
tests[i].S = []rune("communism")
tests[i].Suffix = []rune("ism")
tests[i].Expected = true
i++
tests[i].S = []rune("activate")
tests[i].Suffix = []rune("ate")
tests[i].Expected = true
i++
tests[i].S = []rune("angulariti")
tests[i].Suffix = []rune("iti")
tests[i].Expected = true
i++
tests[i].S = []rune("homologous")
tests[i].Suffix = []rune("ous")
tests[i].Expected = true
i++
tests[i].S = []rune("effective")
tests[i].Suffix = []rune("ive")
tests[i].Expected = true
i++
tests[i].S = []rune("bowdlerize")
tests[i].Suffix = []rune("ize")
tests[i].Expected = true
i++
tests[i].S = []rune("probate")
tests[i].Suffix = []rune("e")
tests[i].Expected = true
i++
tests[i].S = []rune("rate")
tests[i].Suffix = []rune("e")
tests[i].Expected = true
i++
tests[i].S = []rune("cease")
tests[i].Suffix = []rune("e")
tests[i].Expected = true
i++
for _, datum := range tests {
if actual := hasSuffix(datum.S, datum.Suffix); actual != datum.Expected {
t.Errorf("Did NOT get what was expected for calling hasSuffix() on [%s] with suffix [%s]. Expect [%t] but got [%t]", string(datum.S), string(datum.Suffix), datum.Expected, actual)
}
}
}

View file

@ -1,74 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestIsConsontant(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []bool
}, 12)
tests[i].S = []rune("apple")
tests[i].Expected = []bool{false, true, true, true, false}
i++
tests[i].S = []rune("cyan")
tests[i].Expected = []bool{true, false, false, true}
i++
tests[i].S = []rune("connects")
tests[i].Expected = []bool{true, false, true, true, false, true, true, true}
i++
tests[i].S = []rune("yellow")
tests[i].Expected = []bool{true, false, true, true, false, true}
i++
tests[i].S = []rune("excellent")
tests[i].Expected = []bool{false, true, true, false, true, true, false, true, true}
i++
tests[i].S = []rune("yuk")
tests[i].Expected = []bool{true, false, true}
i++
tests[i].S = []rune("syzygy")
tests[i].Expected = []bool{true, false, true, false, true, false}
i++
tests[i].S = []rune("school")
tests[i].Expected = []bool{true, true, true, false, false, true}
i++
tests[i].S = []rune("pay")
tests[i].Expected = []bool{true, false, true}
i++
tests[i].S = []rune("golang")
tests[i].Expected = []bool{true, false, true, false, true, true}
i++
// NOTE: The Porter Stemmer technical should make a mistake on the second "y".
// Really, both the 1st and 2nd "y" are consontants. But
tests[i].S = []rune("sayyid")
tests[i].Expected = []bool{true, false, true, false, false, true}
i++
tests[i].S = []rune("ya")
tests[i].Expected = []bool{true, false}
i++
for _, datum := range tests {
for i = 0; i < len(datum.S); i++ {
if actual := isConsonant(datum.S, i); actual != datum.Expected[i] {
t.Errorf("Did NOT get what was expected for calling isConsonant() on [%s] at [%d] (i.e., [%s]). Expect [%t] but got [%t]", string(datum.S), i, string(datum.S[i]), datum.Expected[i], actual)
}
} // for
}
}

View file

@ -1,99 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestMeasure(t *testing.T) {
tests := make([]struct {
S []rune
Expected uint
}, 27)
tests[0].S = []rune("ya")
tests[0].Expected = 0
tests[1].S = []rune("cyan")
tests[1].Expected = 1
tests[2].S = []rune("connects")
tests[2].Expected = 2
tests[3].S = []rune("yellow")
tests[3].Expected = 2
tests[4].S = []rune("excellent")
tests[4].Expected = 3
tests[5].S = []rune("yuk")
tests[5].Expected = 1
tests[6].S = []rune("syzygy")
tests[6].Expected = 2
tests[7].S = []rune("school")
tests[7].Expected = 1
tests[8].S = []rune("pay")
tests[8].Expected = 1
tests[9].S = []rune("golang")
tests[9].Expected = 2
// NOTE: The Porter Stemmer technical should make a mistake on the second "y".
// Really, both the 1st and 2nd "y" are consontants. But
tests[10].S = []rune("sayyid")
tests[10].Expected = 2
tests[11].S = []rune("ya")
tests[11].Expected = 0
tests[12].S = []rune("")
tests[12].Expected = 0
tests[13].S = []rune("tr")
tests[13].Expected = 0
tests[14].S = []rune("ee")
tests[14].Expected = 0
tests[15].S = []rune("tree")
tests[15].Expected = 0
tests[16].S = []rune("t")
tests[16].Expected = 0
tests[18].S = []rune("by")
tests[18].Expected = 0
tests[19].S = []rune("trouble")
tests[19].Expected = 1
tests[20].S = []rune("oats")
tests[20].Expected = 1
tests[21].S = []rune("trees")
tests[21].Expected = 1
tests[22].S = []rune("ivy")
tests[22].Expected = 1
tests[23].S = []rune("troubles")
tests[23].Expected = 2
tests[24].S = []rune("private")
tests[24].Expected = 2
tests[25].S = []rune("oaten")
tests[25].Expected = 2
tests[26].S = []rune("orrery")
tests[26].Expected = 2
for _, datum := range tests {
if actual := measure(datum.S); actual != datum.Expected {
t.Errorf("Did NOT get what was expected for calling measure() on [%s]. Expect [%d] but got [%d]", string(datum.S), datum.Expected, actual)
}
}
}

View file

@ -1,118 +0,0 @@
package porterstemmer
import (
"bufio"
"io/ioutil"
"net/http"
"os"
"strings"
"testing"
)
func TestStemString(t *testing.T) {
testDataDirName := "testdata"
_, err := os.Stat(testDataDirName)
if nil != err {
_ = os.Mkdir(testDataDirName, 0755)
}
_, err = os.Stat(testDataDirName)
if nil != err {
t.Errorf("The test data folder ([%s]) does not exists (and could not create it). Received error: [%v]", testDataDirName, err)
/////// RETURN
return
}
vocFileName := testDataDirName + "/voc.txt"
_, err = os.Stat(vocFileName)
if nil != err {
vocHref := "http://tartarus.org/martin/PorterStemmer/voc.txt"
resp, err := http.Get(vocHref)
if nil != err {
t.Errorf("Could not download test file (from web) from URL: [%s]. Received error: [%v]", vocHref, err)
/////////// RETURN
return
}
respBody, err := ioutil.ReadAll(resp.Body)
if nil != err {
t.Errorf("Error loading the contents of from URL: [%s]. Received error: [%v].", vocHref, err)
/////////// RETURN
return
}
_ = ioutil.WriteFile(vocFileName, respBody, 0644)
}
vocFd, err := os.Open(vocFileName)
if nil != err {
t.Errorf("Could NOT open testdata file: [%s]. Received error: [%v]", vocFileName, err)
/////// RETURN
return
}
defer vocFd.Close()
voc := bufio.NewReaderSize(vocFd, 1024)
outFileName := testDataDirName + "/output.txt"
_, err = os.Stat(outFileName)
if nil != err {
outHref := "http://tartarus.org/martin/PorterStemmer/output.txt"
resp, err := http.Get(outHref)
if nil != err {
t.Errorf("Could not download test file (from web) from URL: [%s]. Received error: [%v]", outHref, err)
/////////// RETURN
return
}
respBody, err := ioutil.ReadAll(resp.Body)
if nil != err {
t.Errorf("Error loading the contents of from URL: [%s]. Received error: [%v].", outHref, err)
/////////// RETURN
return
}
_ = ioutil.WriteFile(outFileName, respBody, 0644)
}
outFd, err := os.Open(outFileName)
if nil != err {
t.Errorf("Could NOT open testdata file: [%s]. Received error: [%v]", outFileName, err)
/////// RETURN
return
}
defer outFd.Close()
out := bufio.NewReaderSize(outFd, 1024)
for {
vocS, err := voc.ReadString('\n')
if nil != err {
/////// BREAK
break
}
vocS = strings.Trim(vocS, "\n\r\t ")
expected, err := out.ReadString('\n')
if nil != err {
t.Errorf("Received unexpected error when trying to read a line from [%s]. Received error: [%v]", outFileName, err)
/////// BREAK
break
}
expected = strings.Trim(expected, "\n\r\t ")
actual := StemString(vocS)
if expected != actual {
t.Errorf("Input: [%s] -> Actual: [%s]. Expected: [%s]", vocS, actual, expected)
}
}
}

View file

@ -1,56 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStemWithoutLowerCasing(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 3)
tests[i].S = []rune("controll")
tests[i].Expected = []rune("control")
i++
tests[i].S = []rune("roll")
tests[i].Expected = []rune("roll")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = StemWithoutLowerCasing(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling StemWithoutLowerCasing() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}

View file

@ -1,70 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep1a(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 12)
tests[i].S = []rune("caresses")
tests[i].Expected = []rune("caress")
i++
tests[i].S = []rune("ponies")
tests[i].Expected = []rune("poni")
i++
tests[i].S = []rune("ties")
tests[i].Expected = []rune("ti")
i++
tests[i].S = []rune("caress")
tests[i].Expected = []rune("caress")
i++
tests[i].S = []rune("cats")
tests[i].Expected = []rune("cat")
i++
for _, datum := range tests {
for i = 0; i < len(datum.S); i++ {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step1a(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step1a() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
} // for
}
}

View file

@ -1,112 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep1b(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 17)
tests[i].S = []rune("feed")
tests[i].Expected = []rune("feed")
i++
tests[i].S = []rune("agreed")
tests[i].Expected = []rune("agree")
i++
tests[i].S = []rune("plastered")
tests[i].Expected = []rune("plaster")
i++
tests[i].S = []rune("bled")
tests[i].Expected = []rune("bled")
i++
tests[i].S = []rune("motoring")
tests[i].Expected = []rune("motor")
i++
tests[i].S = []rune("sing")
tests[i].Expected = []rune("sing")
i++
tests[i].S = []rune("conflated")
tests[i].Expected = []rune("conflate")
i++
tests[i].S = []rune("troubled")
tests[i].Expected = []rune("trouble")
i++
tests[i].S = []rune("sized")
tests[i].Expected = []rune("size")
i++
tests[i].S = []rune("hopping")
tests[i].Expected = []rune("hop")
i++
tests[i].S = []rune("tanned")
tests[i].Expected = []rune("tan")
i++
tests[i].S = []rune("falling")
tests[i].Expected = []rune("fall")
i++
tests[i].S = []rune("hissing")
tests[i].Expected = []rune("hiss")
i++
tests[i].S = []rune("fizzed")
tests[i].Expected = []rune("fizz")
i++
tests[i].S = []rune("failing")
tests[i].Expected = []rune("fail")
i++
tests[i].S = []rune("filing")
tests[i].Expected = []rune("file")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step1b(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step1b() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}

View file

@ -1,60 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep1c(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 17)
tests[i].S = []rune("happy")
tests[i].Expected = []rune("happi")
i++
tests[i].S = []rune("sky")
tests[i].Expected = []rune("sky")
i++
tests[i].S = []rune("apology")
tests[i].Expected = []rune("apologi")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step1c(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step1c() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}

View file

@ -1,132 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep2(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 22)
tests[i].S = []rune("relational")
tests[i].Expected = []rune("relate")
i++
tests[i].S = []rune("conditional")
tests[i].Expected = []rune("condition")
i++
tests[i].S = []rune("rational")
tests[i].Expected = []rune("rational")
i++
tests[i].S = []rune("valenci")
tests[i].Expected = []rune("valence")
i++
tests[i].S = []rune("hesitanci")
tests[i].Expected = []rune("hesitance")
i++
tests[i].S = []rune("digitizer")
tests[i].Expected = []rune("digitize")
i++
tests[i].S = []rune("conformabli")
tests[i].Expected = []rune("conformable")
i++
tests[i].S = []rune("radicalli")
tests[i].Expected = []rune("radical")
i++
tests[i].S = []rune("differentli")
tests[i].Expected = []rune("different")
i++
tests[i].S = []rune("vileli")
tests[i].Expected = []rune("vile")
i++
tests[i].S = []rune("analogousli")
tests[i].Expected = []rune("analogous")
i++
tests[i].S = []rune("vietnamization")
tests[i].Expected = []rune("vietnamize")
i++
tests[i].S = []rune("predication")
tests[i].Expected = []rune("predicate")
i++
tests[i].S = []rune("operator")
tests[i].Expected = []rune("operate")
i++
tests[i].S = []rune("feudalism")
tests[i].Expected = []rune("feudal")
i++
tests[i].S = []rune("decisiveness")
tests[i].Expected = []rune("decisive")
i++
tests[i].S = []rune("hopefulness")
tests[i].Expected = []rune("hopeful")
i++
tests[i].S = []rune("callousness")
tests[i].Expected = []rune("callous")
i++
tests[i].S = []rune("formaliti")
tests[i].Expected = []rune("formal")
i++
tests[i].S = []rune("sensitiviti")
tests[i].Expected = []rune("sensitive")
i++
tests[i].S = []rune("sensibiliti")
tests[i].Expected = []rune("sensible")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step2(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step2() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}

View file

@ -1,76 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep3(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 22)
tests[i].S = []rune("triplicate")
tests[i].Expected = []rune("triplic")
i++
tests[i].S = []rune("formative")
tests[i].Expected = []rune("form")
i++
tests[i].S = []rune("formalize")
tests[i].Expected = []rune("formal")
i++
tests[i].S = []rune("electriciti")
tests[i].Expected = []rune("electric")
i++
tests[i].S = []rune("electrical")
tests[i].Expected = []rune("electric")
i++
tests[i].S = []rune("hopeful")
tests[i].Expected = []rune("hope")
i++
tests[i].S = []rune("goodness")
tests[i].Expected = []rune("good")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step3(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step3() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}

View file

@ -1,124 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep4(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 20)
tests[i].S = []rune("revival")
tests[i].Expected = []rune("reviv")
i++
tests[i].S = []rune("allowance")
tests[i].Expected = []rune("allow")
i++
tests[i].S = []rune("inference")
tests[i].Expected = []rune("infer")
i++
tests[i].S = []rune("airliner")
tests[i].Expected = []rune("airlin")
i++
tests[i].S = []rune("gyroscopic")
tests[i].Expected = []rune("gyroscop")
i++
tests[i].S = []rune("adjustable")
tests[i].Expected = []rune("adjust")
i++
tests[i].S = []rune("defensible")
tests[i].Expected = []rune("defens")
i++
tests[i].S = []rune("irritant")
tests[i].Expected = []rune("irrit")
i++
tests[i].S = []rune("replacement")
tests[i].Expected = []rune("replac")
i++
tests[i].S = []rune("adjustment")
tests[i].Expected = []rune("adjust")
i++
tests[i].S = []rune("dependent")
tests[i].Expected = []rune("depend")
i++
tests[i].S = []rune("adoption")
tests[i].Expected = []rune("adopt")
i++
tests[i].S = []rune("homologou")
tests[i].Expected = []rune("homolog")
i++
tests[i].S = []rune("communism")
tests[i].Expected = []rune("commun")
i++
tests[i].S = []rune("activate")
tests[i].Expected = []rune("activ")
i++
tests[i].S = []rune("angulariti")
tests[i].Expected = []rune("angular")
i++
tests[i].S = []rune("homologous")
tests[i].Expected = []rune("homolog")
i++
tests[i].S = []rune("effective")
tests[i].Expected = []rune("effect")
i++
tests[i].S = []rune("bowdlerize")
tests[i].Expected = []rune("bowdler")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step4(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step4() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}

View file

@ -1,60 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep5a(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 3)
tests[i].S = []rune("probate")
tests[i].Expected = []rune("probat")
i++
tests[i].S = []rune("rate")
tests[i].Expected = []rune("rate")
i++
tests[i].S = []rune("cease")
tests[i].Expected = []rune("ceas")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step5a(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step5a() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}

View file

@ -1,56 +0,0 @@
package porterstemmer
import (
"testing"
)
func TestStep5b(t *testing.T) {
i := 0
tests := make([]struct {
S []rune
Expected []rune
}, 3)
tests[i].S = []rune("controll")
tests[i].Expected = []rune("control")
i++
tests[i].S = []rune("roll")
tests[i].Expected = []rune("roll")
i++
for _, datum := range tests {
actual := make([]rune, len(datum.S))
copy(actual, datum.S)
actual = step5b(actual)
lenActual := len(actual)
lenExpected := len(datum.Expected)
equal := true
if 0 == lenActual && 0 == lenExpected {
equal = true
} else if lenActual != lenExpected {
equal = false
} else if actual[0] != datum.Expected[0] {
equal = false
} else if actual[lenActual-1] != datum.Expected[lenExpected-1] {
equal = false
} else {
for j := 0; j < lenActual; j++ {
if actual[j] != datum.Expected[j] {
equal = false
}
}
}
if !equal {
t.Errorf("Did NOT get what was expected for calling step5b() on [%s]. Expect [%s] but got [%s]", string(datum.S), string(datum.Expected), string(actual))
}
}
}