| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package internal |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/stretchr/testify/assert" |
| 10 |
|
| 11 |
"go.opentelemetry.io/collector/internal/testutil" |
| 12 |
) |
| 13 |
|
| 14 |
func TestAssertMutable(t *testing.T) { |
| 15 |
assert.NotPanics(t, func() { NewState().AssertMutable() }) |
| 16 |
assert.Panics(t, func() { |
| 17 |
state := NewState() |
| 18 |
state.MarkReadOnly() |
| 19 |
state.AssertMutable() |
| 20 |
}) |
| 21 |
} |
| 22 |
|
| 23 |
func BenchmarkAssertMutable(b *testing.B) { |
| 24 |
testutil.SkipMemoryBench(b) |
| 25 |
b.ReportAllocs() |
| 26 |
|
| 27 |
mutable := NewState() |
| 28 |
for b.Loop() { |
| 29 |
mutable.AssertMutable() |
| 30 |
} |
| 31 |
} |