| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package utils |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "testing" |
||
| 5 | |||
| 6 | "github.com/stretchr/testify/assert" |
||
| 7 | ) |
||
| 8 | |||
| 9 | func TestCenterString_WithNormalString(t *testing.T) { |
||
| 10 | result := CenterString("test", 10) |
||
| 11 | assert.Equal(t, " test ", result) |
||
| 12 | } |
||
| 13 | |||
| 14 | func TestCenterString_WithEmptyString(t *testing.T) { |
||
| 15 | result := CenterString("", 10) |
||
| 16 | assert.Equal(t, " ", result) |
||
| 17 | } |
||
| 18 | |||
| 19 | func TestCenterString_WithCenteredString(t *testing.T) { |
||
| 20 | result := CenterString(" test ", 10) |
||
| 21 | assert.Equal(t, " test ", result) |
||
| 22 | } |
||
| 23 | |||
| 24 | func TestCenterString_WithLongString(t *testing.T) { |
||
| 25 | result := CenterString("this is a long string", 10) |
||
| 26 | assert.Equal(t, "this is a long string", result) |
||
| 27 | } |
||
| 28 | |||
| 29 | func TestCenterString_WithOddWidth(t *testing.T) { |
||
| 30 | result := CenterString("test", 11) |
||
| 31 | assert.Equal(t, " test ", result) |
||
| 32 | } |
||
| 33 |