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

Function TestAppendBytes

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

Source from the content-addressed store, hash-verified

177}
178
179func TestAppendBytes(t *testing.T) {
180 for _, tt := range encodeByteTests {
181 b := enc.AppendBytes([]byte{}, tt.plain)
182 if got, want := string(b), tt.binary; got != want {
183 t.Errorf("appendString(%q) = %#q, want %#q", tt.plain, got, want)
184 }
185 }
186 //Test a large string > 65535 length
187
188 inp := []byte{}
189 for i := 0; i < 0x00011170; i++ { //70,000 character string
190 inp = append(inp, byte('a'))
191 }
192 want := "\x5a\x00\x01\x11\x70" + string(inp)
193 b := enc.AppendBytes([]byte{}, inp)
194 if got := string(b); got != want {
195 t.Errorf("appendString(%q) = %#q, want %#q", inp, got, want)
196 }
197}
198
199func BenchmarkAppendString(b *testing.B) {
200 tests := map[string]string{

Callers

nothing calls this directly

Calls 1

AppendBytesMethod · 0.65

Tested by

no test coverage detected