MCPcopy
hub / github.com/gofiber/fiber / Test_App_quoteRawString

Function Test_App_quoteRawString

helpers_test.go:1614–1639  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1612}
1613
1614func Test_App_quoteRawString(t *testing.T) {
1615 t.Parallel()
1616
1617 cases := []struct {
1618 name string
1619 in string
1620 out string
1621 }{
1622 {"empty", "", ""},
1623 {"simple", "simple", "simple"},
1624 {"backslash", "A\\B", "A\\\\B"},
1625 {"quote", `He said "Yo"`, `He said \"Yo\"`},
1626 {"newline", "Hello\n", "Hello\\n"},
1627 {"carriage", "Hello\r", "Hello\\r"},
1628 {"controls", string([]byte{0, 31, 127}), "%00%1F%7F"},
1629 {"mixed", "test \"A\n\r" + string([]byte{1}) + "\\", `test \"A\n\r%01\\`},
1630 }
1631
1632 for _, tc := range cases {
1633 t.Run(tc.name, func(t *testing.T) {
1634 t.Parallel()
1635 app := New()
1636 require.Equal(t, tc.out, app.quoteRawString(tc.in))
1637 })
1638 }
1639}
1640
1641func Test_App_quoteString_DetachesFromPooledBuffer(t *testing.T) {
1642 t.Parallel()

Callers

nothing calls this directly

Calls 2

quoteRawStringMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected