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.
24 lines
459 B
24 lines
459 B
package lastword_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.jxs.me/leetgo/lastword"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestExamples(t *testing.T) {
|
|
cases := map[string]int{
|
|
"": 0,
|
|
"hello": 5,
|
|
"hello computer": 8,
|
|
" goodbye my friend ": 6,
|
|
}
|
|
for input, expected := range cases {
|
|
t.Run(input, func(t *testing.T) {
|
|
result := lastword.LengthOfLastWord(input)
|
|
require.Equal(t, expected, result)
|
|
})
|
|
}
|
|
}
|