| 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/require" |
| 10 |
gootlpcommon "go.opentelemetry.io/proto/slim/otlp/common/v1" |
| 11 |
goproto "google.golang.org/protobuf/proto" |
| 12 |
) |
| 13 |
|
| 14 |
func TestAnyValueBytes(t *testing.T) { |
| 15 |
av := &gootlpcommon.AnyValue{Value: &gootlpcommon.AnyValue_BytesValue{BytesValue: nil}} |
| 16 |
buf, err := goproto.Marshal(av) |
| 17 |
require.NoError(t, err) |
| 18 |
|
| 19 |
pav := &AnyValue{Value: &AnyValue_BytesValue{BytesValue: nil}} |
| 20 |
pbuf := make([]byte, pav.SizeProto()) |
| 21 |
n := pav.MarshalProto(pbuf) |
| 22 |
pbuf = pbuf[:n] |
| 23 |
require.Equal(t, buf, pbuf) |
| 24 |
} |