MCPcopy
hub / github.com/rs/zerolog / TestAppendString

Function TestAppendString

internal/cbor/string_test.go:74–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestAppendString(t *testing.T) {
75 for _, tt := range encodeStringTests {
76 b := enc.AppendString([]byte{}, tt.plain)
77 if got, want := string(b), tt.binary; got != want {
78 t.Errorf("appendString(%q) = %#q, want %#q", tt.plain, got, want)
79 }
80 }
81 //Test a large string > 65535 length
82
83 var buffer bytes.Buffer
84 for i := 0; i < 0x00011170; i++ { //70,000 character string
85 buffer.WriteString("a")
86 }
87 inp := buffer.String()
88 want := "\x7a\x00\x01\x11\x70" + inp
89 b := enc.AppendString([]byte{}, inp)
90 if got := string(b); got != want {
91 t.Errorf("appendString(%q) = %#q, want %#q", inp, got, want)
92 }
93}
94func TestAppendStrings(t *testing.T) {
95 array := []string{}
96 for _, tt := range encodeStringTests {

Callers

nothing calls this directly

Calls 2

AppendStringMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected