Refactor utils/utils, fixes #11923

Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Antonio Murdaca 2015-03-29 23:17:23 +02:00
parent b15e56b3ef
commit d7a5d5b94c
10 changed files with 328 additions and 10 deletions

View file

@ -56,3 +56,32 @@ func TestGenerateRandomAsciiStringIsAscii(t *testing.T) {
t.Fatalf("%s contained non-ascii characters", str)
}
}
func TestTruncate(t *testing.T) {
str := "teststring"
newstr := Truncate(str, 4)
if newstr != "test" {
t.Fatalf("Expected test, got %s", newstr)
}
newstr = Truncate(str, 20)
if newstr != "teststring" {
t.Fatalf("Expected teststring, got %s", newstr)
}
}
func TestInSlice(t *testing.T) {
slice := []string{"test", "in", "slice"}
test := InSlice(slice, "test")
if !test {
t.Fatalf("Expected string test to be in slice")
}
test = InSlice(slice, "SLICE")
if !test {
t.Fatalf("Expected string SLICE to be in slice")
}
test = InSlice(slice, "notinslice")
if test {
t.Fatalf("Expected string notinslice not to be in slice")
}
}