repo_description: A modern and intuitive terminal-based text editor
repo_topics: command-line cross-platform editor go golang micro terminal text-editor
code: package 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)
  }
  