github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/strutil/eol_sol_test.go (about)

     1  package strutil
     2  
     3  import "testing"
     4  
     5  var EOLSOLTests = []struct {
     6  	s                         string
     7  	wantFirstEOL, wantLastSOL int
     8  }{
     9  	{"0", 1, 0},
    10  	{"\n12", 0, 1},
    11  	{"01\n", 2, 3},
    12  	{"01\n34", 2, 3},
    13  }
    14  
    15  func TestEOLSOL(t *testing.T) {
    16  	for _, tc := range EOLSOLTests {
    17  		eol := FindFirstEOL(tc.s)
    18  		if eol != tc.wantFirstEOL {
    19  			t.Errorf("FindFirstEOL(%q) => %d, want %d", tc.s, eol, tc.wantFirstEOL)
    20  		}
    21  		sol := FindLastSOL(tc.s)
    22  		if sol != tc.wantLastSOL {
    23  			t.Errorf("FindLastSOL(%q) => %d, want %d", tc.s, sol, tc.wantLastSOL)
    24  		}
    25  	}
    26  }