github.com/sandwich-go/boost@v1.3.29/xstrings/escape_test.go (about)

     1  package xstrings
     2  
     3  import (
     4  	. "github.com/smartystreets/goconvey/convey"
     5  	"testing"
     6  )
     7  
     8  func TestEscapeStringBackslash(t *testing.T) {
     9  	Convey("escape string backslash", t, func() {
    10  		So(EscapeStringBackslash("foo\x00bar"), ShouldEqual, "foo\\0bar")
    11  		So(EscapeStringBackslash("foo\nbar"), ShouldEqual, "foo\\nbar")
    12  		So(EscapeStringBackslash("foo\rbar"), ShouldEqual, "foo\\rbar")
    13  		So(EscapeStringBackslash("foo\x1abar"), ShouldEqual, "foo\\Zbar")
    14  		So(EscapeStringBackslash("foo\"bar"), ShouldEqual, "foo\\\"bar")
    15  		So(EscapeStringBackslash("foo\\bar"), ShouldEqual, "foo\\\\bar")
    16  		So(EscapeStringBackslash("foo'bar"), ShouldEqual, "foo\\'bar")
    17  	})
    18  }