2021-02-14 02:09:56 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestDictionary(t *testing.T) {
|
|
|
|
d := Dictionary{}
|
|
|
|
|
2021-02-20 20:52:27 +00:00
|
|
|
d.AddWord("INC", Word{
|
|
|
|
Name: "INC",
|
|
|
|
Source: []string{"1", "+"},
|
|
|
|
})
|
2021-02-14 02:09:56 +00:00
|
|
|
w, err := d.GetWord("INC")
|
|
|
|
if err != nil {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
if w.Name != "INC" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
if w.Impl != nil {
|
|
|
|
t.Fail()
|
|
|
|
}
|
2021-02-14 19:27:02 +00:00
|
|
|
if len(w.Source) != 2 || w.Source[0] != "1" || w.Source[1] != "+" {
|
2021-02-14 02:09:56 +00:00
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|