From ecbb4a10a52050ad25ac0384f6e149aa7cd0447f Mon Sep 17 00:00:00 2001 From: Don Date: Fri, 18 Sep 2020 10:58:48 -0700 Subject: [PATCH] Add test for negative truncation --- template/helpers_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/template/helpers_test.go b/template/helpers_test.go index 96d6e6e..b93339d 100644 --- a/template/helpers_test.go +++ b/template/helpers_test.go @@ -53,6 +53,22 @@ func TestTruncate(t *testing.T) { } } +func TestNegativeTruncate(t *testing.T) { + vals := map[string]string{ + "foobarz": "rz", + "foöäüüu": "üu", + "üpsßßßk": "ßk", + "1234567": "67", + "!'§$%&/": "&/", + } + + for input, want := range vals { + if got := truncate(input, -5); got != want { + t.Errorf("Want transform %s to %s, got %s", input, want, got) + } + } +} + func TestSince(t *testing.T) { t.Skip() }