github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/readline/tabgrid_test.go (about)

     1  package readline
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/lmorg/murex/test/count"
     8  )
     9  
    10  func TestCropCaption(t *testing.T) {
    11  	count.Tests(t, 1)
    12  	// We aren't really bothered about the quality of the output here, just
    13  	// testing that the function doesn't generate any slice out of bounds
    14  	// exceptions
    15  
    16  	var caption, maxLen, cellWidth int
    17  
    18  	defer func() {
    19  		if r := recover(); r != nil {
    20  			t.Errorf("panic raised on iteration %d,%d,%d: %s", caption, maxLen, cellWidth, r)
    21  		}
    22  	}()
    23  
    24  	for caption = 0; caption < 101; caption++ {
    25  		for maxLen = 0; maxLen < 101; maxLen++ {
    26  			for cellWidth = 0; cellWidth < 101; cellWidth++ {
    27  				_ = cropCaption(strings.Repeat("s", caption), maxLen, cellWidth)
    28  			}
    29  		}
    30  	}
    31  }