MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestFromLabelAdaptersToLabelsWithCopy

Function TestFromLabelAdaptersToLabelsWithCopy

pkg/cortexpb/compat_test.go:118–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestFromLabelAdaptersToLabelsWithCopy(t *testing.T) {
119 input := []LabelAdapter{{Name: "hello", Value: "world"}}
120 expected := labels.FromStrings("hello", "world")
121 actual := FromLabelAdaptersToLabelsWithCopy(input)
122
123 assert.Equal(t, expected, actual)
124
125 final := FromLabelsToLabelAdapters(actual)
126 // All strings must be copied.
127 assert.NotEqual(t, uintptr(unsafe.Pointer(&input[0].Name)), uintptr(unsafe.Pointer(&final[0].Name)))
128 assert.NotEqual(t, uintptr(unsafe.Pointer(&input[0].Value)), uintptr(unsafe.Pointer(&final[0].Value)))
129}
130
131func BenchmarkFromLabelAdaptersToLabelsWithCopy(b *testing.B) {
132 input := []LabelAdapter{

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.65

Tested by

no test coverage detected