-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathunit_to_ucum_test.go
60 lines (56 loc) · 1006 Bytes
/
unit_to_ucum_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package prometheus // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus"
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUnitWordToUCUM(t *testing.T) {
for _, tc := range []struct {
input string
expected string
}{
{
input: "",
expected: "",
},
{
input: "days",
expected: "d",
},
{
input: "seconds",
expected: "s",
},
{
input: "kibibytes",
expected: "KiBy",
},
{
input: "volts",
expected: "V",
},
{
input: "bananas_per_day",
expected: "bananas/d",
},
{
input: "meters_per_hour",
expected: "m/h",
},
{
input: "ratio",
expected: "1",
},
{
input: "percent",
expected: "%",
},
} {
t.Run(fmt.Sprintf("input: \"%v\"", tc.input), func(t *testing.T) {
got := UnitWordToUCUM(tc.input)
assert.Equal(t, tc.expected, got)
})
}
}