| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package exemplar |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/stretchr/testify/assert" |
| 10 |
) |
| 11 |
|
| 12 |
func TestValue(t *testing.T) { |
| 13 |
const iVal, fVal, nVal = int64(43), float64(0.3), int64(-42) |
| 14 |
i, f, n, bad := NewValue[int64](iVal), NewValue[float64](fVal), NewValue[int64](nVal), Value{} |
| 15 |
|
| 16 |
assert.Equal(t, Int64ValueType, i.Type()) |
| 17 |
assert.Equal(t, iVal, i.Int64()) |
| 18 |
assert.Equal(t, float64(0), i.Float64()) |
| 19 |
|
| 20 |
assert.Equal(t, Float64ValueType, f.Type()) |
| 21 |
assert.Equal(t, fVal, f.Float64()) |
| 22 |
assert.Equal(t, int64(0), f.Int64()) |
| 23 |
|
| 24 |
assert.Equal(t, Int64ValueType, n.Type()) |
| 25 |
assert.Equal(t, nVal, n.Int64()) |
| 26 |
assert.Equal(t, float64(0), i.Float64()) |
| 27 |
|
| 28 |
assert.Equal(t, UnknownValueType, bad.Type()) |
| 29 |
assert.Equal(t, float64(0), bad.Float64()) |
| 30 |
assert.Equal(t, int64(0), bad.Int64()) |
| 31 |
} |