53 lines
1010 B
Go
53 lines
1010 B
Go
package common
|
|
|
|
import "testing"
|
|
|
|
func TestUnify(t *testing.T) {
|
|
if "foo" != Unify("foo") {
|
|
t.Errorf(`"foo" has to be untouched by unify`)
|
|
}
|
|
|
|
if "foo" != Unify("Foo") {
|
|
t.Errorf(`"Foo" needs to be lowercase after test`)
|
|
}
|
|
|
|
if "foo" != Unify(" Foo") {
|
|
t.Errorf(`The spaces need to be stripped`)
|
|
}
|
|
|
|
if "foo" != Unify(" Foo ") {
|
|
t.Errorf(`The spaces need to be stripped`)
|
|
}
|
|
|
|
if "foo bar" != Unify("Foo bar") {
|
|
t.Errorf(`Single whitespaces need to be left alone`)
|
|
}
|
|
|
|
if "foo bar" != Unify("Foo bar") {
|
|
t.Errorf(`Double whitespaces need to be removed`)
|
|
}
|
|
|
|
if "foo bar" != Unify("Foo bar") {
|
|
t.Errorf(`Double whitespaces need to be removed`)
|
|
}
|
|
|
|
if "foo bar baz" != Unify("Foo bar baz") {
|
|
t.Errorf(`Double whitespaces need to be removed`)
|
|
}
|
|
}
|
|
|
|
func TestZeroPad(t *testing.T) {
|
|
cases := map[int]string{
|
|
0: "000",
|
|
5: "005",
|
|
1000: "1000",
|
|
50: "050",
|
|
}
|
|
|
|
for key, val := range cases {
|
|
if res := ZeroPad(key, 3); res != val {
|
|
t.Errorf(`did not match`)
|
|
}
|
|
}
|
|
}
|