MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestEscapeQuotedString

Function TestEscapeQuotedString

pkg/sql/ast/value_test.go:326–349  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

324}
325
326func TestEscapeQuotedString(t *testing.T) {
327 tests := []struct {
328 input string
329 quote rune
330 expected string
331 }{
332 {"hello", '\'', "hello"},
333 {"O'Reilly", '\'', "O''Reilly"},
334 {`"quoted"`, '"', `""quoted""`},
335 {"mixed'\"quotes", '\'', "mixed''\"quotes"},
336 {"mixed'\"quotes", '"', "mixed'\"\"quotes"},
337 {`escaped\'quote`, '\'', `escaped\'quote`},
338 {`escaped\"quote`, '"', `escaped\"quote`},
339 }
340
341 for _, tt := range tests {
342 t.Run(tt.input, func(t *testing.T) {
343 got := escapeQuotedString(tt.input, tt.quote)
344 if got != tt.expected {
345 t.Errorf("escapeQuotedString() with quote %c = %v, want %v", tt.quote, got, tt.expected)
346 }
347 })
348 }
349}
350
351// Test additional Value.String() cases for byte string literals
352func TestValueStringByteStringLiterals(t *testing.T) {

Callers

nothing calls this directly

Calls 3

escapeQuotedStringFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected