5
5
"testing"
6
6
)
7
7
8
+ // only tests that work on 32 bit architectures or both go here
9
+ // tests only working on 64 bit architectures go in _amd64_test.go
8
10
func TestIsCompatible (t * testing.T ) {
9
11
cases := []struct {
10
12
t MetricType
@@ -15,16 +17,34 @@ func TestIsCompatible(t *testing.T) {
15
17
{Int64Type , - 1 , true },
16
18
{Uint64Type , - 1 , false },
17
19
{Uint32Type , - 1 , false },
18
- {Int32Type , 2147483648 , false },
19
- {Int64Type , 2147483648 , true },
20
- {Int32Type , int32 (- 2147483648 ), true },
21
- {Int64Type , int64 (- 2147483648 ), true },
22
- {Uint32Type , int32 (- 2147483648 ), false },
23
- {Uint64Type , int64 (- 2147483648 ), false },
20
+
21
+ {Int32Type , math .MinInt32 , true },
22
+ {Int64Type , math .MinInt32 , true },
23
+ {Uint32Type , math .MinInt32 , false },
24
+ {Uint64Type , math .MinInt32 , false },
25
+
26
+ {Int32Type , int32 (math .MinInt32 ), true },
27
+ {Int64Type , int64 (math .MinInt32 ), true },
28
+ {Uint32Type , int32 (math .MinInt32 ), false },
29
+ {Uint64Type , int64 (math .MinInt32 ), false },
30
+
31
+ {Int32Type , math .MaxInt32 , true },
32
+ {Int64Type , math .MaxInt32 , true },
33
+ {Uint32Type , math .MaxInt32 , true },
34
+ {Uint64Type , math .MaxInt32 , true },
35
+
36
+ {Int32Type , int32 (math .MaxInt32 ), true },
37
+ {Int64Type , int64 (math .MaxInt32 ), true },
38
+ {Uint32Type , int32 (math .MaxInt32 ), false },
39
+ {Uint64Type , int64 (math .MaxInt32 ), false },
40
+
41
+ {Int64Type , int64 (math .MaxInt64 ), true },
42
+
24
43
{Uint32Type , uint32 (math .MaxUint32 ), true },
25
44
{Uint64Type , uint64 (math .MaxUint32 ), true },
45
+
26
46
{Uint32Type , uint (math .MaxUint32 ), true },
27
- { Uint64Type , uint ( math . MaxUint64 ), true },
47
+
28
48
{Uint32Type , math .MaxUint32 , true },
29
49
{Uint64Type , uint64 (math .MaxUint64 ), true },
30
50
}
@@ -36,3 +56,38 @@ func TestIsCompatible(t *testing.T) {
36
56
}
37
57
}
38
58
}
59
+
60
+ func TestResolve (t * testing.T ) {
61
+ cases := []struct {
62
+ t MetricType
63
+ val , resval interface {}
64
+ }{
65
+ {Int32Type , 10 , int32 (10 )},
66
+ {Int64Type , 10 , int64 (10 )},
67
+ {Uint32Type , 10 , uint32 (10 )},
68
+ {Uint64Type , 10 , uint64 (10 )},
69
+
70
+ {Int32Type , int32 (10 ), int32 (10 )},
71
+ {Int64Type , int64 (10 ), int64 (10 )},
72
+ {Uint32Type , uint32 (10 ), uint32 (10 )},
73
+ {Uint64Type , uint64 (10 ), uint64 (10 )},
74
+
75
+ {Uint32Type , uint (10 ), uint32 (10 )},
76
+ {Uint64Type , uint (10 ), uint64 (10 )},
77
+
78
+ {Uint32Type , uint32 (10 ), uint32 (10 )},
79
+ {Uint64Type , uint64 (10 ), uint64 (10 )},
80
+
81
+ {FloatType , 3.14 , float32 (3.14 )},
82
+ {DoubleType , 3.14 , float64 (3.14 )},
83
+
84
+ {FloatType , float32 (3.14 ), float32 (3.14 )},
85
+ {DoubleType , float64 (3.14 ), float64 (3.14 )},
86
+ }
87
+
88
+ for _ , c := range cases {
89
+ if c .t .resolve (c .val ) != c .resval {
90
+ t .Errorf ("expected %T to resolve to %T" , c .val , c .resval )
91
+ }
92
+ }
93
+ }
0 commit comments