github.com/ali-iotechsys/cli@v20.10.0+incompatible/opts/quotedstring_test.go (about)

     1  package opts
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gotest.tools/v3/assert"
     7  	is "gotest.tools/v3/assert/cmp"
     8  )
     9  
    10  func TestQuotedStringSetWithQuotes(t *testing.T) {
    11  	value := ""
    12  	qs := NewQuotedString(&value)
    13  	assert.NilError(t, qs.Set(`"something"`))
    14  	assert.Check(t, is.Equal("something", qs.String()))
    15  	assert.Check(t, is.Equal("something", value))
    16  }
    17  
    18  func TestQuotedStringSetWithMismatchedQuotes(t *testing.T) {
    19  	value := ""
    20  	qs := NewQuotedString(&value)
    21  	assert.NilError(t, qs.Set(`"something'`))
    22  	assert.Check(t, is.Equal(`"something'`, qs.String()))
    23  }
    24  
    25  func TestQuotedStringSetWithNoQuotes(t *testing.T) {
    26  	value := ""
    27  	qs := NewQuotedString(&value)
    28  	assert.NilError(t, qs.Set("something"))
    29  	assert.Check(t, is.Equal("something", qs.String()))
    30  }