aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthias Loibl <mail@matthiasloibl.com>2016-11-07 21:37:08 +0100
committerMatthias Loibl <mail@matthiasloibl.com>2016-11-07 23:31:40 +0100
commitb00d82d67902b03298aedf6828b0c738398153a7 (patch)
treee3aec33ef53bbda05d11bbee7a8bee52cf4401b2 /modules
parent86c32f2706d9865194d06b8eec53727785d70567 (diff)
downloadgitea-b00d82d67902b03298aedf6828b0c738398153a7.tar.gz
gitea-b00d82d67902b03298aedf6828b0c738398153a7.zip
Add tests for TruncateString()
Diffstat (limited to 'modules')
-rw-r--r--modules/base/tool_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go
index b29c8ea717..5b69a45983 100644
--- a/modules/base/tool_test.go
+++ b/modules/base/tool_test.go
@@ -105,7 +105,17 @@ func TestEllipsisString(t *testing.T) {
assert.Equal(t, "foobar", EllipsisString("foobar", 10))
}
-// TODO: TruncateString()
+func TestTruncateString(t *testing.T) {
+ assert.Equal(t, "", TruncateString("foobar", 0))
+ assert.Equal(t, "f", TruncateString("foobar", 1))
+ assert.Equal(t, "fo", TruncateString("foobar", 2))
+ assert.Equal(t, "foo", TruncateString("foobar", 3))
+ assert.Equal(t, "foob", TruncateString("foobar", 4))
+ assert.Equal(t, "fooba", TruncateString("foobar", 5))
+ assert.Equal(t, "foobar", TruncateString("foobar", 6))
+ assert.Equal(t, "foobar", TruncateString("foobar", 7))
+}
+
// TODO: StringsToInt64s()
// TODO: Int64sToStrings()
// TODO: Int64sToMap()