github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/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 }