MCPcopy
hub / github.com/grafana/tempo / TestPadTraceIDTo16Bytes

Function TestPadTraceIDTo16Bytes

pkg/util/traceid_test.go:352–380  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

350}
351
352func TestPadTraceIDTo16Bytes(t *testing.T) {
353 tc := []struct {
354 name string
355 tid []byte
356 expected []byte
357 }{
358 {
359 name: "small",
360 tid: []byte{0x01, 0x02},
361 expected: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02},
362 },
363 {
364 name: "exact",
365 tid: []byte{0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02},
366 expected: []byte{0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02},
367 },
368 { // least significant bits are preserved
369 name: "large",
370 tid: []byte{0x05, 0x05, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02},
371 expected: []byte{0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02},
372 },
373 }
374
375 for _, tt := range tc {
376 t.Run(tt.name, func(t *testing.T) {
377 assert.Equal(t, tt.expected, PadTraceIDTo16Bytes(tt.tid))
378 })
379 }
380}
381
382func TestHexStringToSpanID(t *testing.T) {
383 tc := []struct {

Callers

nothing calls this directly

Calls 3

PadTraceIDTo16BytesFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected