| 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 TestExponentialHistogram_MoveTo(t *testing.T) { |
| 18 |
ms := generateTestExponentialHistogram() |
| 19 |
dest := NewExponentialHistogram() |
| 20 |
ms.MoveTo(dest) |
| 21 |
assert.Equal(t, NewExponentialHistogram(), ms) |
| 22 |
assert.Equal(t, generateTestExponentialHistogram(), dest) |
| 23 |
dest.MoveTo(dest) |
| 24 |
assert.Equal(t, generateTestExponentialHistogram(), dest) |
| 25 |
sharedState := internal.NewState() |
| 26 |
sharedState.MarkReadOnly() |
| 27 |
assert.Panics(t, func() { ms.MoveTo(newExponentialHistogram(internal.NewExponentialHistogram(), sharedState)) }) |
| 28 |
assert.Panics(t, func() { newExponentialHistogram(internal.NewExponentialHistogram(), sharedState).MoveTo(dest) }) |
| 29 |
} |
| 30 |
|
| 31 |
func TestExponentialHistogram_CopyTo(t *testing.T) { |
| 32 |
ms := NewExponentialHistogram() |
| 33 |
orig := NewExponentialHistogram() |
| 34 |
orig.CopyTo(ms) |
| 35 |
assert.Equal(t, orig, ms) |
| 36 |
orig = generateTestExponentialHistogram() |
| 37 |
orig.CopyTo(ms) |
| 38 |
assert.Equal(t, orig, ms) |
| 39 |
sharedState := internal.NewState() |
| 40 |
sharedState.MarkReadOnly() |
| 41 |
assert.Panics(t, func() { ms.CopyTo(newExponentialHistogram(internal.NewExponentialHistogram(), sharedState)) }) |
| 42 |
} |
| 43 |
|
| 44 |
func TestExponentialHistogram_DataPoints(t *testing.T) { |
| 45 |
ms := NewExponentialHistogram() |
| 46 |
assert.Equal(t, NewExponentialHistogramDataPointSlice(), ms.DataPoints()) |
| 47 |
ms.orig.DataPoints = internal.GenTestExponentialHistogramDataPointPtrSlice() |
| 48 |
assert.Equal(t, generateTestExponentialHistogramDataPointSlice(), ms.DataPoints()) |
| 49 |
} |
| 50 |
|
| 51 |
func TestExponentialHistogram_AggregationTemporality(t *testing.T) { |
| 52 |
ms := NewExponentialHistogram() |
| 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 generateTestExponentialHistogram() ExponentialHistogram { |
| 60 |
return newExponentialHistogram(internal.GenTestExponentialHistogram(), internal.NewState()) |
| 61 |
} |