Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Oct 13, 2023
1 parent df68b86 commit 2575975
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bridge/opencensus/internal/ocmetric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package internal // import "go.opentelemetry.io/otel/bridge/opencensus/internal/
import (
"errors"
"fmt"
"math"
"reflect"
"sort"
"strconv"
Expand Down Expand Up @@ -305,8 +306,7 @@ func intSliceKV[N int8 | int16 | int32](key string, val []N) attribute.KeyValue
}

func uintKV(key string, val uint) attribute.KeyValue {
const maxInt = ^uint(0) >> 1
if val > maxInt {
if val > uint(math.MaxInt) {
return uint64KV(key, uint64(val))
}
return attribute.Int(key, int(val))
Expand Down
16 changes: 12 additions & 4 deletions bridge/opencensus/internal/ocmetric/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,10 @@ func TestConvertKV(t *testing.T) {
value: uint(10),
expected: attribute.IntValue(10),
},
{
value: uint(math.MaxUint),
expected: attribute.StringValue("18446744073709551615"),
},
{
value: []uint{10, 20},
expected: attribute.StringSliceValue([]string{"10", "20"}),
Expand All @@ -882,10 +886,6 @@ func TestConvertKV(t *testing.T) {
value: uint32(10),
expected: attribute.IntValue(10),
},
{
value: uint32(math.MaxUint32),
expected: attribute.Int64Value(math.MaxUint32),
},
{
value: []uint32{10, 20},
expected: attribute.StringSliceValue([]string{"10", "20"}),
Expand All @@ -910,6 +910,14 @@ func TestConvertKV(t *testing.T) {
value: []uintptr{10, 20},
expected: attribute.StringSliceValue([]string{"10", "20"}),
},
{
value: float32(10),
expected: attribute.Float64Value(10),
},
{
value: []float32{10, 20},
expected: attribute.Float64SliceValue([]float64{10, 20}),
},
{
value: float64(10),
expected: attribute.Float64Value(10),
Expand Down

0 comments on commit 2575975

Please sign in to comment.