Debian Codegraph @

pdata/pprofile/generated_location_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 // Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT.
5 // To regenerate this file run "make genpdata".
6
7 package pprofile
8
9 import (
10 "testing"
11
12 "github.com/stretchr/testify/assert"
13
14 "go.opentelemetry.io/collector/pdata/internal"
15 "go.opentelemetry.io/collector/pdata/pcommon"
16 )
17
18 func TestLocation_MoveTo(t *testing.T) {
19 ms := generateTestLocation()
20 dest := NewLocation()
21 ms.MoveTo(dest)
22 assert.Equal(t, NewLocation(), ms)
23 assert.Equal(t, generateTestLocation(), dest)
24 dest.MoveTo(dest)
25 assert.Equal(t, generateTestLocation(), dest)
26 sharedState := internal.NewState()
27 sharedState.MarkReadOnly()
28 assert.Panics(t, func() { ms.MoveTo(newLocation(internal.NewLocation(), sharedState)) })
29 assert.Panics(t, func() { newLocation(internal.NewLocation(), sharedState).MoveTo(dest) })
30 }
31
32 func TestLocation_CopyTo(t *testing.T) {
33 ms := NewLocation()
34 orig := NewLocation()
35 orig.CopyTo(ms)
36 assert.Equal(t, orig, ms)
37 orig = generateTestLocation()
38 orig.CopyTo(ms)
39 assert.Equal(t, orig, ms)
40 sharedState := internal.NewState()
41 sharedState.MarkReadOnly()
42 assert.Panics(t, func() { ms.CopyTo(newLocation(internal.NewLocation(), sharedState)) })
43 }
44
45 func TestLocation_MappingIndex(t *testing.T) {
46 ms := NewLocation()
47 assert.Equal(t, int32(0), ms.MappingIndex())
48 ms.SetMappingIndex(int32(13))
49 assert.Equal(t, int32(13), ms.MappingIndex())
50 sharedState := internal.NewState()
51 sharedState.MarkReadOnly()
52 assert.Panics(t, func() { newLocation(internal.NewLocation(), sharedState).SetMappingIndex(int32(13)) })
53 }
54
55 func TestLocation_Address(t *testing.T) {
56 ms := NewLocation()
57 assert.Equal(t, uint64(0), ms.Address())
58 ms.SetAddress(uint64(13))
59 assert.Equal(t, uint64(13), ms.Address())
60 sharedState := internal.NewState()
61 sharedState.MarkReadOnly()
62 assert.Panics(t, func() { newLocation(internal.NewLocation(), sharedState).SetAddress(uint64(13)) })
63 }
64
65 func TestLocation_Lines(t *testing.T) {
66 ms := NewLocation()
67 assert.Equal(t, NewLineSlice(), ms.Lines())
68 ms.orig.Lines = internal.GenTestLinePtrSlice()
69 assert.Equal(t, generateTestLineSlice(), ms.Lines())
70 }
71
72 func TestLocation_AttributeIndices(t *testing.T) {
73 ms := NewLocation()
74 assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices())
75 ms.orig.AttributeIndices = internal.GenTestInt32Slice()
76 assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.AttributeIndices())
77 }
78
79 func generateTestLocation() Location {
80 return newLocation(internal.GenTestLocation(), internal.NewState())
81 }