generate: Test encoding floating point values
This commit is contained in:
parent
3ef7de118b
commit
8b63166ba1
@ -220,6 +220,9 @@ func TestGenerateRun(test *testing.T) {
|
|||||||
Fields: map[uint16] Field {
|
Fields: map[uint16] Field {
|
||||||
0x0000: Field { Name: "Index", Type: TypeInt { Bits: 5 } },
|
0x0000: Field { Name: "Index", Type: TypeInt { Bits: 5 } },
|
||||||
0x0001: Field { Name: "Offset", Type: TypeInt { Bits: 16, Signed: true }},
|
0x0001: Field { Name: "Offset", Type: TypeInt { Bits: 16, Signed: true }},
|
||||||
|
0x0002: Field { Name: "X", Type: TypeFloat { Bits: 16 }},
|
||||||
|
0x0003: Field { Name: "Y", Type: TypeFloat { Bits: 32 }},
|
||||||
|
0x0004: Field { Name: "Z", Type: TypeFloat { Bits: 64 }},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -287,12 +290,18 @@ func TestGenerateRun(test *testing.T) {
|
|||||||
messagePulse := MessagePulse {
|
messagePulse := MessagePulse {
|
||||||
Index: 9,
|
Index: 9,
|
||||||
Offset: -0x3521,
|
Offset: -0x3521,
|
||||||
|
X: 45.389,
|
||||||
|
Y: 294.1,
|
||||||
|
Z: 384729384.234892034,
|
||||||
}
|
}
|
||||||
testEncode(
|
testEncode(
|
||||||
&messagePulse,
|
&messagePulse,
|
||||||
tu.S(0xC1, 0x02).AddVar(
|
tu.S(0xC1, 0x02).AddVar(
|
||||||
[]byte { 0x00, 0x00, 0x09 },
|
[]byte { 0x00, 0x00, 0x09 },
|
||||||
[]byte { 0x00, 0x01, 0x21, 0xCA, 0xDF },
|
[]byte { 0x00, 0x01, 0x21, 0xCA, 0xDF },
|
||||||
|
[]byte { 0x00, 0x02, 0x41, 0x3F, 0x80 },
|
||||||
|
[]byte { 0x00, 0x03, 0x43, 0x43, 0x93, 0x0C, 0xCD },
|
||||||
|
[]byte { 0x00, 0x04, 0x47, 0x41, 0xB6, 0xEE, 0x81, 0x28, 0x3C, 0x21, 0xE2 },
|
||||||
))
|
))
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user