summaryrefslogtreecommitdiffstats
path: root/modules/base/tool_test.go
diff options
context:
space:
mode:
authorMatthias Loibl <mail@matthiasloibl.com>2016-11-07 21:27:14 +0100
committerMatthias Loibl <mail@matthiasloibl.com>2016-11-07 23:31:39 +0100
commit030ba2894f3e9f9442b4bbf83fec09bda1ca88c5 (patch)
tree4e186189b1062603887284d4cae20b6c166b8ebe /modules/base/tool_test.go
parentf81711f40d46208917742b871c41fe74a4b214c1 (diff)
downloadgitea-030ba2894f3e9f9442b4bbf83fec09bda1ca88c5.tar.gz
gitea-030ba2894f3e9f9442b4bbf83fec09bda1ca88c5.zip
Add tests for EllipsisString() and fix bug if param length < 3
Diffstat (limited to 'modules/base/tool_test.go')
-rw-r--r--modules/base/tool_test.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go
index bc46a2a883..b29c8ea717 100644
--- a/modules/base/tool_test.go
+++ b/modules/base/tool_test.go
@@ -68,14 +68,11 @@ func TestAvatarLink(t *testing.T) {
)
}
-// TODO: AvatarLink()
// TODO: computeTimeDiff()
// TODO: TimeSincePro()
// TODO: timeSince()
// TODO: RawTimeSince()
// TODO: TimeSince()
-// TODO: logn()
-// TODO: humanateBytes()
func TestFileSize(t *testing.T) {
var size int64
@@ -96,7 +93,18 @@ func TestFileSize(t *testing.T) {
}
// TODO: Subtract()
-// TODO: EllipsisString()
+
+func TestEllipsisString(t *testing.T) {
+ assert.Equal(t, "...", EllipsisString("foobar", 0))
+ assert.Equal(t, "...", EllipsisString("foobar", 1))
+ assert.Equal(t, "...", EllipsisString("foobar", 2))
+ assert.Equal(t, "...", EllipsisString("foobar", 3))
+ assert.Equal(t, "f...", EllipsisString("foobar", 4))
+ assert.Equal(t, "fo...", EllipsisString("foobar", 5))
+ assert.Equal(t, "foobar", EllipsisString("foobar", 6))
+ assert.Equal(t, "foobar", EllipsisString("foobar", 10))
+}
+
// TODO: TruncateString()
// TODO: StringsToInt64s()
// TODO: Int64sToStrings()