github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/pkg/strutil/chop_test.go (about)

     1  package strutil
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "src.elv.sh/pkg/tt"
     7  )
     8  
     9  func TestChopLineEnding(t *testing.T) {
    10  	Test(t, Fn("ChopLineEnding", ChopLineEnding), Table{
    11  		Args("").Rets(""),
    12  		Args("text").Rets("text"),
    13  		Args("text\n").Rets("text"),
    14  		Args("text\r\n").Rets("text"),
    15  		// Only chop off one line ending
    16  		Args("text\n\n").Rets("text\n"),
    17  		// Preserve internal line endings
    18  		Args("text\ntext 2\n").Rets("text\ntext 2"),
    19  	})
    20  }