| 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 |
) |
| 16 |
|
| 17 |
func TestSum_MoveTo(t *testing.T) { |
| 18 |
ms := generateTestSum() |
| 19 |
dest := NewSum() |
| 20 |
ms.MoveTo(dest) |
| 21 |
assert.Equal(t, NewSum(), ms) |
| 22 |
assert.Equal(t, generateTestSum(), dest) |
| 23 |
dest.MoveTo(dest) |
| 24 |
assert.Equal(t, generateTestSum(), dest) |
| 25 |
sharedState := internal.NewState() |
| 26 |
sharedState.MarkReadOnly() |
| 27 |
assert.Panics(t, func() { ms.MoveTo(newSum(internal.NewSum(), sharedState)) }) |
| 28 |
assert.Panics(t, func() { newSum(internal.NewSum(), sharedState).MoveTo(dest) }) |
| 29 |
} |
| 30 |
|
| 31 |
func TestSum_CopyTo(t *testing.T) { |
| 32 |
ms := NewSum() |
| 33 |
orig := NewSum() |
| 34 |
orig.CopyTo(ms) |
| 35 |
assert.Equal(t, orig, ms) |
| 36 |
orig = generateTestSum() |
| 37 |
orig.CopyTo(ms) |
| 38 |
assert.Equal(t, orig, ms) |
| 39 |
sharedState := internal.NewState() |
| 40 |
sharedState.MarkReadOnly() |
| 41 |
assert.Panics(t, func() { ms.CopyTo(newSum(internal.NewSum(), sharedState)) }) |
| 42 |
} |
| 43 |
|
| 44 |
func TestSum_DataPoints(t *testing.T) { |
| 45 |
ms := NewSum() |
| 46 |
assert.Equal(t, NewNumberDataPointSlice(), ms.DataPoints()) |
| 47 |
ms.orig.DataPoints = internal.GenTestNumberDataPointPtrSlice() |
| 48 |
assert.Equal(t, generateTestNumberDataPointSlice(), ms.DataPoints()) |
| 49 |
} |
| 50 |
|
| 51 |
func TestSum_AggregationTemporality(t *testing.T) { |
| 52 |
ms := NewSum() |
| 53 |
assert.Equal(t, AggregationTemporality(internal.AggregationTemporality(0)), ms.AggregationTemporality()) |
| 54 |
testValAggregationTemporality := AggregationTemporality(internal.AggregationTemporality(1)) |
| 55 |
ms.SetAggregationTemporality(testValAggregationTemporality) |
| 56 |
assert.Equal(t, testValAggregationTemporality, ms.AggregationTemporality()) |
| 57 |
} |
| 58 |
|
| 59 |
func TestSum_IsMonotonic(t *testing.T) { |
| 60 |
ms := NewSum() |
| 61 |
assert.False(t, ms.IsMonotonic()) |
| 62 |
ms.SetIsMonotonic(true) |
| 63 |
assert.True(t, ms.IsMonotonic()) |
| 64 |
sharedState := internal.NewState() |
| 65 |
sharedState.MarkReadOnly() |
| 66 |
assert.Panics(t, func() { newSum(internal.NewSum(), sharedState).SetIsMonotonic(true) }) |
| 67 |
} |
| 68 |
|
| 69 |
func generateTestSum() Sum { |
| 70 |
return newSum(internal.GenTestSum(), internal.NewState()) |
| 71 |
} |