You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

string_test.go 305B

123456789101112131415161718192021
  1. package util
  2. import (
  3. "testing"
  4. )
  5. func TestTruncate(t *testing.T) {
  6. if Truncate("Test", 5) != "Test" {
  7. t.Fail()
  8. }
  9. if Truncate("Test", 3) != "" {
  10. t.Fail()
  11. }
  12. if Truncate("This is a test", 9) != "This is…" {
  13. t.Fail()
  14. }
  15. if Truncate("This is a test", 10) != "This is a…" {
  16. t.Fail()
  17. }
  18. }