generate: Test encoding floating point values

This commit is contained in:
Sasha Koshka 2025-07-21 14:57:22 -04:00
parent 3ef7de118b
commit 8b63166ba1

View File

@ -220,6 +220,9 @@ func TestGenerateRun(test *testing.T) {
Fields: map[uint16] Field {
0x0000: Field { Name: "Index", Type: TypeInt { Bits: 5 } },
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 {
Index: 9,
Offset: -0x3521,
X: 45.389,
Y: 294.1,
Z: 384729384.234892034,
}
testEncode(
&messagePulse,
tu.S(0xC1, 0x02).AddVar(
[]byte { 0x00, 0x00, 0x09 },
[]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 },
))
`)
}