Something went wrong. Try again.
Fork of micro-editor/micro
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334package util
import ( "testing"
"github.com/stretchr/testify/assert")
func TestStringWidth(t *testing.T) { bytes := []byte("\tPot să \tmănânc sticlă și ea nu mă rănește.")
n := StringWidth(bytes, 23, 4) assert.Equal(t, 26, n)}
func TestSliceVisualEnd(t *testing.T) { s := []byte("\thello") slc, n, _ := SliceVisualEnd(s, 2, 4) assert.Equal(t, []byte("\thello"), slc) assert.Equal(t, 2, n)
slc, n, _ = SliceVisualEnd(s, 1, 4) assert.Equal(t, []byte("\thello"), slc) assert.Equal(t, 1, n)
slc, n, _ = SliceVisualEnd(s, 4, 4) assert.Equal(t, []byte("hello"), slc) assert.Equal(t, 0, n)
slc, n, _ = SliceVisualEnd(s, 5, 4) assert.Equal(t, []byte("ello"), slc) assert.Equal(t, 0, n)}