gilo/internal/gilo/fn_test.go
Timothy J. Warren 3672c5c3e9
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
Complete kilo chapter 5, fix backspace and delete behavior
2021-04-06 10:30:12 -04:00

38 lines
665 B
Go

package gilo
import (
"testing"
)
func TestTruncateString(t *testing.T) {
firstString := "abcdefghijklmnopqrstuvwxyz"
truncated := Truncate(firstString, 13)
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)
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)
want := str
if got != want {
t.Errorf("Truncated value: %q, expected value: %q", got, want)
}
}