| 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 TestSummaryDataPointValueAtQuantile_MoveTo(t *testing.T) { |
| 18 |
ms := generateTestSummaryDataPointValueAtQuantile() |
| 19 |
dest := NewSummaryDataPointValueAtQuantile() |
| 20 |
ms.MoveTo(dest) |
| 21 |
assert.Equal(t, NewSummaryDataPointValueAtQuantile(), ms) |
| 22 |
assert.Equal(t, generateTestSummaryDataPointValueAtQuantile(), dest) |
| 23 |
dest.MoveTo(dest) |
| 24 |
assert.Equal(t, generateTestSummaryDataPointValueAtQuantile(), dest) |
| 25 |
sharedState := internal.NewState() |
| 26 |
sharedState.MarkReadOnly() |
| 27 |
assert.Panics(t, func() { |
| 28 |
ms.MoveTo(newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState)) |
| 29 |
}) |
| 30 |
assert.Panics(t, func() { |
| 31 |
newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState).MoveTo(dest) |
| 32 |
}) |
| 33 |
} |
| 34 |
|
| 35 |
func TestSummaryDataPointValueAtQuantile_CopyTo(t *testing.T) { |
| 36 |
ms := NewSummaryDataPointValueAtQuantile() |
| 37 |
orig := NewSummaryDataPointValueAtQuantile() |
| 38 |
orig.CopyTo(ms) |
| 39 |
assert.Equal(t, orig, ms) |
| 40 |
orig = generateTestSummaryDataPointValueAtQuantile() |
| 41 |
orig.CopyTo(ms) |
| 42 |
assert.Equal(t, orig, ms) |
| 43 |
sharedState := internal.NewState() |
| 44 |
sharedState.MarkReadOnly() |
| 45 |
assert.Panics(t, func() { |
| 46 |
ms.CopyTo(newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState)) |
| 47 |
}) |
| 48 |
} |
| 49 |
|
| 50 |
func TestSummaryDataPointValueAtQuantile_Quantile(t *testing.T) { |
| 51 |
ms := NewSummaryDataPointValueAtQuantile() |
| 52 |
assert.InDelta(t, float64(0), ms.Quantile(), 0.01) |
| 53 |
ms.SetQuantile(float64(3.1415926)) |
| 54 |
assert.InDelta(t, float64(3.1415926), ms.Quantile(), 0.01) |
| 55 |
sharedState := internal.NewState() |
| 56 |
sharedState.MarkReadOnly() |
| 57 |
assert.Panics(t, func() { |
| 58 |
newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState).SetQuantile(float64(3.1415926)) |
| 59 |
}) |
| 60 |
} |
| 61 |
|
| 62 |
func TestSummaryDataPointValueAtQuantile_Value(t *testing.T) { |
| 63 |
ms := NewSummaryDataPointValueAtQuantile() |
| 64 |
assert.InDelta(t, float64(0), ms.Value(), 0.01) |
| 65 |
ms.SetValue(float64(3.1415926)) |
| 66 |
assert.InDelta(t, float64(3.1415926), ms.Value(), 0.01) |
| 67 |
sharedState := internal.NewState() |
| 68 |
sharedState.MarkReadOnly() |
| 69 |
assert.Panics(t, func() { |
| 70 |
newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState).SetValue(float64(3.1415926)) |
| 71 |
}) |
| 72 |
} |
| 73 |
|
| 74 |
func generateTestSummaryDataPointValueAtQuantile() SummaryDataPointValueAtQuantile { |
| 75 |
return newSummaryDataPointValueAtQuantile(internal.GenTestSummaryDataPointValueAtQuantile(), internal.NewState()) |
| 76 |
} |