| 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 pmetric |
| 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 TestSummaryDataPoint_MoveTo(t *testing.T) { |
| 19 |
ms := generateTestSummaryDataPoint() |
| 20 |
dest := NewSummaryDataPoint() |
| 21 |
ms.MoveTo(dest) |
| 22 |
assert.Equal(t, NewSummaryDataPoint(), ms) |
| 23 |
assert.Equal(t, generateTestSummaryDataPoint(), dest) |
| 24 |
dest.MoveTo(dest) |
| 25 |
assert.Equal(t, generateTestSummaryDataPoint(), dest) |
| 26 |
sharedState := internal.NewState() |
| 27 |
sharedState.MarkReadOnly() |
| 28 |
assert.Panics(t, func() { ms.MoveTo(newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState)) }) |
| 29 |
assert.Panics(t, func() { newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState).MoveTo(dest) }) |
| 30 |
} |
| 31 |
|
| 32 |
func TestSummaryDataPoint_CopyTo(t *testing.T) { |
| 33 |
ms := NewSummaryDataPoint() |
| 34 |
orig := NewSummaryDataPoint() |
| 35 |
orig.CopyTo(ms) |
| 36 |
assert.Equal(t, orig, ms) |
| 37 |
orig = generateTestSummaryDataPoint() |
| 38 |
orig.CopyTo(ms) |
| 39 |
assert.Equal(t, orig, ms) |
| 40 |
sharedState := internal.NewState() |
| 41 |
sharedState.MarkReadOnly() |
| 42 |
assert.Panics(t, func() { ms.CopyTo(newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState)) }) |
| 43 |
} |
| 44 |
|
| 45 |
func TestSummaryDataPoint_Attributes(t *testing.T) { |
| 46 |
ms := NewSummaryDataPoint() |
| 47 |
assert.Equal(t, pcommon.NewMap(), ms.Attributes()) |
| 48 |
ms.orig.Attributes = internal.GenTestKeyValueSlice() |
| 49 |
assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) |
| 50 |
} |
| 51 |
|
| 52 |
func TestSummaryDataPoint_StartTimestamp(t *testing.T) { |
| 53 |
ms := NewSummaryDataPoint() |
| 54 |
assert.Equal(t, pcommon.Timestamp(0), ms.StartTimestamp()) |
| 55 |
testValStartTimestamp := pcommon.Timestamp(1234567890) |
| 56 |
ms.SetStartTimestamp(testValStartTimestamp) |
| 57 |
assert.Equal(t, testValStartTimestamp, ms.StartTimestamp()) |
| 58 |
} |
| 59 |
|
| 60 |
func TestSummaryDataPoint_Timestamp(t *testing.T) { |
| 61 |
ms := NewSummaryDataPoint() |
| 62 |
assert.Equal(t, pcommon.Timestamp(0), ms.Timestamp()) |
| 63 |
testValTimestamp := pcommon.Timestamp(1234567890) |
| 64 |
ms.SetTimestamp(testValTimestamp) |
| 65 |
assert.Equal(t, testValTimestamp, ms.Timestamp()) |
| 66 |
} |
| 67 |
|
| 68 |
func TestSummaryDataPoint_Count(t *testing.T) { |
| 69 |
ms := NewSummaryDataPoint() |
| 70 |
assert.Equal(t, uint64(0), ms.Count()) |
| 71 |
ms.SetCount(uint64(13)) |
| 72 |
assert.Equal(t, uint64(13), ms.Count()) |
| 73 |
sharedState := internal.NewState() |
| 74 |
sharedState.MarkReadOnly() |
| 75 |
assert.Panics(t, func() { newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState).SetCount(uint64(13)) }) |
| 76 |
} |
| 77 |
|
| 78 |
func TestSummaryDataPoint_Sum(t *testing.T) { |
| 79 |
ms := NewSummaryDataPoint() |
| 80 |
assert.InDelta(t, float64(0), ms.Sum(), 0.01) |
| 81 |
ms.SetSum(float64(3.1415926)) |
| 82 |
assert.InDelta(t, float64(3.1415926), ms.Sum(), 0.01) |
| 83 |
sharedState := internal.NewState() |
| 84 |
sharedState.MarkReadOnly() |
| 85 |
assert.Panics(t, func() { newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState).SetSum(float64(3.1415926)) }) |
| 86 |
} |
| 87 |
|
| 88 |
func TestSummaryDataPoint_QuantileValues(t *testing.T) { |
| 89 |
ms := NewSummaryDataPoint() |
| 90 |
assert.Equal(t, NewSummaryDataPointValueAtQuantileSlice(), ms.QuantileValues()) |
| 91 |
ms.orig.QuantileValues = internal.GenTestSummaryDataPointValueAtQuantilePtrSlice() |
| 92 |
assert.Equal(t, generateTestSummaryDataPointValueAtQuantileSlice(), ms.QuantileValues()) |
| 93 |
} |
| 94 |
|
| 95 |
func TestSummaryDataPoint_Flags(t *testing.T) { |
| 96 |
ms := NewSummaryDataPoint() |
| 97 |
assert.Equal(t, DataPointFlags(0), ms.Flags()) |
| 98 |
testValFlags := DataPointFlags(1) |
| 99 |
ms.SetFlags(testValFlags) |
| 100 |
assert.Equal(t, testValFlags, ms.Flags()) |
| 101 |
} |
| 102 |
|
| 103 |
func generateTestSummaryDataPoint() SummaryDataPoint { |
| 104 |
return newSummaryDataPoint(internal.GenTestSummaryDataPoint(), internal.NewState()) |
| 105 |
} |