hishtory/client/tui/tui_test.go

17 lines
559 B
Go
Raw Normal View History

package tui
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCalculateWordBoundaries(t *testing.T) {
require.Equal(t, []int{0, 3}, calculateWordBoundaries("foo"))
require.Equal(t, []int{0, 3, 7}, calculateWordBoundaries("foo bar"))
require.Equal(t, []int{0, 3, 7}, calculateWordBoundaries("foo-bar"))
require.Equal(t, []int{0, 3, 7, 11}, calculateWordBoundaries("foo-bar baz"))
require.Equal(t, []int{0, 3, 10, 16}, calculateWordBoundaries("foo-- -bar - baz"))
require.Equal(t, []int{0, 3}, calculateWordBoundaries("foo "))
}