MCPcopy Create free account
hub / github.com/lib/pq / TestAppendEncodedText

Function TestAppendEncodedText

encode_test.go:368–388  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

366}
367
368func TestAppendEncodedText(t *testing.T) {
369 must := func(buf []byte, x any) []byte {
370 t.Helper()
371 buf, err := appendEncodedText(buf, x)
372 if err != nil {
373 t.Fatal(err)
374 }
375 return buf
376 }
377
378 buf := must(nil, int64(10))
379 buf = append(buf, '\t')
380 buf = must(buf, 42.0000000001)
381 buf = append(buf, '\t')
382 buf = must(buf, "hello\tworld")
383 buf = append(buf, '\t')
384 buf = must(buf, []byte{0, 128, 255})
385 if string(buf) != "10\t42.0000000001\thello\\tworld\t\\\\x0080ff" {
386 t.Fatal(string(buf))
387 }
388}
389
390func TestAppendEscapedText(t *testing.T) {
391 buf := appendEscapedText(nil, "hallo\tescape")

Callers

nothing calls this directly

Calls 2

appendEncodedTextFunction · 0.85
FatalMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…