1
0
Fork 0
gilo/internal/gilo/fn_test.go

38 lines
665 B
Go
Raw Normal View History

package gilo
2021-03-30 19:37:02 -04:00
import (
"testing"
)
func TestTruncateString(t *testing.T) {
firstString := "abcdefghijklmnopqrstuvwxyz"
truncated := Truncate(firstString, 13)
2021-03-30 19:37:02 -04:00
got := len(truncated)
want := 13
if got != want {
t.Errorf("Truncated length: %q, expected length: %q", got, want)
}
}
func TestTruncateStringNegative(t *testing.T) {
got := Truncate("fdlkjf", -5)
2021-03-30 19:37:02 -04:00
want := ""
if got != want {
t.Errorf("Truncated value: %q, expected value: %q", got, want)
}
}
func TestTruncateShorterString(t *testing.T) {
str := "abcdefg"
got := Truncate(str, 13)
2021-03-30 19:37:02 -04:00
want := str
if got != want {
t.Errorf("Truncated value: %q, expected value: %q", got, want)
}
}