mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestShouldSplitIntoEvenStringsOfFour(t *testing.T) {
|
||
|
input := "abcdefghijkl"
|
||
|
arrayOfStrings := SliceString(input, 4)
|
||
|
assert.Equal(t, len(arrayOfStrings), 3)
|
||
|
assert.Equal(t, "abcd", arrayOfStrings[0])
|
||
|
assert.Equal(t, "efgh", arrayOfStrings[1])
|
||
|
assert.Equal(t, "ijkl", arrayOfStrings[2])
|
||
|
}
|
||
|
|
||
|
func TestShouldSplitIntoEvenStringsOfOne(t *testing.T) {
|
||
|
input := "abcdefghijkl"
|
||
|
arrayOfStrings := SliceString(input, 1)
|
||
|
assert.Equal(t, 12, len(arrayOfStrings))
|
||
|
assert.Equal(t, "a", arrayOfStrings[0])
|
||
|
assert.Equal(t, "b", arrayOfStrings[1])
|
||
|
assert.Equal(t, "c", arrayOfStrings[2])
|
||
|
assert.Equal(t, "d", arrayOfStrings[3])
|
||
|
assert.Equal(t, "l", arrayOfStrings[11])
|
||
|
}
|
||
|
|
||
|
func TestShouldSplitIntoUnevenStringsOfFour(t *testing.T) {
|
||
|
input := "abcdefghijklm"
|
||
|
arrayOfStrings := SliceString(input, 4)
|
||
|
assert.Equal(t, len(arrayOfStrings), 4)
|
||
|
assert.Equal(t, "abcd", arrayOfStrings[0])
|
||
|
assert.Equal(t, "efgh", arrayOfStrings[1])
|
||
|
assert.Equal(t, "ijkl", arrayOfStrings[2])
|
||
|
assert.Equal(t, "m", arrayOfStrings[3])
|
||
|
}
|