Files
h/sort-cli/content_test.go

54 lines
657 B
Go

package sortcli
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
const input = `
Zimbabwe
Africa
America
Zimbabwe
Africa
`
func TestLoad(t *testing.T) {
c := &Content{}
c.Load(strings.NewReader(input))
assert.Equal(t, input, c.String())
}
func TestUnique(t *testing.T) {
cases := []struct {
Name string
Content string
Expected string
}{
{
"Unique",
input,
`
Zimbabwe
Africa
America`,
},
}
for _, tc := range cases {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
c := &Content{}
c.Load(strings.NewReader(tc.Content))
c.Uniques()
assert.Equal(t, tc.Expected, c.String())
})
}
}