-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataidentifier_test.go
70 lines (66 loc) · 1.42 KB
/
dataidentifier_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
61
62
63
64
65
66
67
68
69
70
package xsens
import (
"fmt"
"testing"
"gotest.tools/v3/assert"
)
func TestDataIdentifier_GetSetUint16(t *testing.T) {
for _, tt := range []struct {
dataIdentifier DataIdentifier
value uint16
}{
{
dataIdentifier: DataIdentifier{
DataType: DataTypeQuaternion,
Precision: PrecisionFloat64,
CoordinateSystem: CoordinateSystemNorthWestUp,
},
value: 0x201b,
},
} {
tt := tt
t.Run(fmt.Sprintf("%#x", tt.value), func(t *testing.T) {
t.Run("Uint16", func(t *testing.T) {
assert.Equal(t, tt.value, tt.dataIdentifier.Uint16())
})
t.Run("SetUint16", func(t *testing.T) {
var actual DataIdentifier
actual.SetUint16(tt.value)
assert.DeepEqual(t, tt.dataIdentifier, actual)
})
})
}
}
func TestDataIdentifier_DataSize(t *testing.T) {
for _, tt := range []struct {
dataIdentifier DataIdentifier
dataSize uint8
}{
{
dataIdentifier: DataIdentifier{
DataType: DataTypeTemperature,
Precision: PrecisionFloat64,
},
dataSize: 8,
},
{
dataIdentifier: DataIdentifier{
DataType: DataTypeAcceleration,
Precision: PrecisionFP1220,
},
dataSize: 12,
},
{
dataIdentifier: DataIdentifier{
DataType: DataTypeQuaternion,
Precision: PrecisionFloat32,
},
dataSize: 16,
},
} {
tt := tt
t.Run(tt.dataIdentifier.String(), func(t *testing.T) {
assert.Equal(t, tt.dataSize, tt.dataIdentifier.DataSize())
})
}
}