1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-25 08:59:31 -05:00

Add tests for TruncateString()

This commit is contained in:
Matthias Loibl 2016-11-07 21:37:08 +01:00
parent 86c32f2706
commit b00d82d679
No known key found for this signature in database
GPG key ID: B1C7DF661ABB2C1A

View file

@ -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()