generate: Update tests with new TNs
This commit is contained in:
parent
02196edf61
commit
0e03f84b8a
@ -230,6 +230,26 @@ func TestGenerateRun(test *testing.T) {
|
||||
Name: "NestedArray",
|
||||
Type: TypeArray { Element: TypeArray { Element: TypeInt { Bits: 8 } } },
|
||||
}
|
||||
protocol.Messages[0x0004] = Message {
|
||||
Name: "Integers",
|
||||
Type: TypeTableDefined {
|
||||
Fields: map[uint16] Field {
|
||||
0x0000: Field { Name: "U5", Type: TypeInt { Bits: 5 } },
|
||||
0x0001: Field { Name: "U8", Type: TypeInt { Bits: 8 } },
|
||||
0x0002: Field { Name: "U16", Type: TypeInt { Bits: 16 } },
|
||||
0x0003: Field { Name: "U32", Type: TypeInt { Bits: 32 } },
|
||||
0x0004: Field { Name: "U64", Type: TypeInt { Bits: 64 } },
|
||||
0x0006: Field { Name: "I8", Type: TypeInt { Bits: 8, Signed: true } },
|
||||
0x0007: Field { Name: "I16", Type: TypeInt { Bits: 16, Signed: true } },
|
||||
0x0008: Field { Name: "I32", Type: TypeInt { Bits: 32, Signed: true } },
|
||||
0x0009: Field { Name: "I64", Type: TypeInt { Bits: 64, Signed: true } },
|
||||
0x000B: Field { Name: "NI8", Type: TypeInt { Bits: 8, Signed: true } },
|
||||
0x000C: Field { Name: "NI16",Type: TypeInt { Bits: 16, Signed: true } },
|
||||
0x000D: Field { Name: "NI32",Type: TypeInt { Bits: 32, Signed: true } },
|
||||
0x000E: Field { Name: "NI64",Type: TypeInt { Bits: 64, Signed: true } },
|
||||
},
|
||||
},
|
||||
}
|
||||
protocol.Types["User"] = TypeTableDefined {
|
||||
Fields: map[uint16] Field {
|
||||
0x0000: Field { Name: "Name", Type: TypeString { } },
|
||||
@ -248,9 +268,9 @@ func TestGenerateRun(test *testing.T) {
|
||||
}
|
||||
testEncode(
|
||||
&messageConnect,
|
||||
tu.S(0xC1, 0x02).AddVar(
|
||||
[]byte { 0x00, 0x00, 0x66, 'r', 'a', 'r', 'i', 't', 'y' },
|
||||
[]byte { 0x00, 0x01, 0x64, 'g', 'e', 'm', 's' },
|
||||
tu.S(0xE1, 0x02).AddVar(
|
||||
[]byte { 0x00, 0x00, 0x86, 'r', 'a', 'r', 'i', 't', 'y' },
|
||||
[]byte { 0x00, 0x01, 0x84, 'g', 'e', 'm', 's' },
|
||||
))
|
||||
log.Println("MessageUserList")
|
||||
messageUserList := MessageUserList {
|
||||
@ -274,19 +294,19 @@ func TestGenerateRun(test *testing.T) {
|
||||
}
|
||||
testEncode(
|
||||
&messageUserList,
|
||||
tu.S(0xC1, 0x01, 0x00, 0x00,
|
||||
0xA1, 0x03, 0xC1,
|
||||
tu.S(0xE1, 0x01, 0x00, 0x00,
|
||||
0xC1, 0x03, 0xE1,
|
||||
).Add(0x03).AddVar(
|
||||
[]byte { 0x00, 0x00, 0x66, 'r', 'a', 'r', 'i', 't', 'y' },
|
||||
[]byte { 0x00, 0x01, 0x67, 'a', 's', 'd', 'j', 'a', 'd', 's' },
|
||||
[]byte { 0x00, 0x00, 0x86, 'r', 'a', 'r', 'i', 't', 'y' },
|
||||
[]byte { 0x00, 0x01, 0x87, 'a', 's', 'd', 'j', 'a', 'd', 's' },
|
||||
[]byte { 0x00, 0x02, 0x23, 0x00, 0x00, 0x03, 0x24 },
|
||||
).Add(0x03).AddVar(
|
||||
[]byte { 0x00, 0x00, 0x69, 'd', 'e', 'e', 'z', ' ', 'n', 'u', 't', 's' },
|
||||
[]byte { 0x00, 0x01, 0x64, 'l', 'o', 'g', 'y' },
|
||||
[]byte { 0x00, 0x00, 0x89, 'd', 'e', 'e', 'z', ' ', 'n', 'u', 't', 's' },
|
||||
[]byte { 0x00, 0x01, 0x84, 'l', 'o', 'g', 'y' },
|
||||
[]byte { 0x00, 0x02, 0x23, 0x00, 0x00, 0x80, 0x00 },
|
||||
).Add(0x03).AddVar(
|
||||
[]byte { 0x00, 0x00, 0x69, 'c', 'r', 'e', 'e', 'k', 'f', 'l', 'o', 'w' },
|
||||
[]byte { 0x00, 0x01, 0x6C, 'i', 'm', ' ', 'c', 'r', 'e', 'e', 'k', 'f',
|
||||
[]byte { 0x00, 0x00, 0x89, 'c', 'r', 'e', 'e', 'k', 'f', 'l', 'o', 'w' },
|
||||
[]byte { 0x00, 0x01, 0x8C, 'i', 'm', ' ', 'c', 'r', 'e', 'e', 'k', 'f',
|
||||
'l', 'o', 'w' },
|
||||
[]byte { 0x00, 0x02, 0x23, 0x00, 0x00, 0x38, 0x94 },
|
||||
))
|
||||
@ -300,12 +320,12 @@ func TestGenerateRun(test *testing.T) {
|
||||
}
|
||||
testEncode(
|
||||
&messagePulse,
|
||||
tu.S(0xC1, 0x05).AddVar(
|
||||
tu.S(0xE1, 0x05).AddVar(
|
||||
[]byte { 0x00, 0x00, 0x09 },
|
||||
[]byte { 0x00, 0x01, 0x21, 0xCA, 0xDF },
|
||||
[]byte { 0x00, 0x02, 0x41, 0x51, 0xAC },
|
||||
[]byte { 0x00, 0x03, 0x43, 0x43, 0x93, 0x0C, 0xCD },
|
||||
[]byte { 0x00, 0x04, 0x47, 0x41, 0xB6, 0xEE, 0x81, 0x28, 0x3C, 0x21, 0xE2 },
|
||||
[]byte { 0x00, 0x01, 0x41, 0xCA, 0xDF },
|
||||
[]byte { 0x00, 0x02, 0x61, 0x51, 0xAC },
|
||||
[]byte { 0x00, 0x03, 0x63, 0x43, 0x93, 0x0C, 0xCD },
|
||||
[]byte { 0x00, 0x04, 0x67, 0x41, 0xB6, 0xEE, 0x81, 0x28, 0x3C, 0x21, 0xE2 },
|
||||
))
|
||||
log.Println("MessageNestedArray")
|
||||
uint8s := func(n int) []uint8 {
|
||||
@ -321,7 +341,7 @@ func TestGenerateRun(test *testing.T) {
|
||||
}
|
||||
testEncode(
|
||||
&messageNestedArray,
|
||||
tu.S(0xA1, 0x02, 0xA1,
|
||||
tu.S(0xC1, 0x02, 0xC1,
|
||||
0x06, 0x20, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6,
|
||||
35, 0x20, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6,
|
||||
0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC,
|
||||
@ -329,5 +349,38 @@ func TestGenerateRun(test *testing.T) {
|
||||
0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
|
||||
0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE,
|
||||
0xFF, 0xF0, 0xF1, 0xF2, 0xF3))
|
||||
log.Println("MessageIntegers")
|
||||
messageIntegers := MessageIntegers {
|
||||
U5: 0x13,
|
||||
U8: 0xC9,
|
||||
U16: 0x34C9,
|
||||
U32: 0x10E134C9,
|
||||
U64: 0x639109BC10E134C9,
|
||||
I8: 0x35,
|
||||
I16: 0x34C9,
|
||||
I32: 0x10E134C9,
|
||||
I64: 0x639109BC10E134C9,
|
||||
NI8: -0x35,
|
||||
NI16: -0x34C9,
|
||||
NI32: -0x10E134C9,
|
||||
NI64: -0x639109BC10E134C9,
|
||||
}
|
||||
testEncode(
|
||||
&messageIntegers,
|
||||
tu.S(0xE1, 13).AddVar(
|
||||
[]byte { 0x00, 0x00, 0x13 },
|
||||
[]byte { 0x00, 0x01, 0x20, 0xC9 },
|
||||
[]byte { 0x00, 0x02, 0x21, 0x34, 0xC9 },
|
||||
[]byte { 0x00, 0x03, 0x23, 0x10, 0xE1, 0x34, 0xC9 },
|
||||
[]byte { 0x00, 0x04, 0x27, 0x63, 0x91, 0x09, 0xBC, 0x10, 0xE1, 0x34, 0xC9 },
|
||||
[]byte { 0x00, 0x06, 0x40, 0x35 },
|
||||
[]byte { 0x00, 0x07, 0x41, 0x34, 0xC9 },
|
||||
[]byte { 0x00, 0x08, 0x43, 0x10, 0xE1, 0x34, 0xC9 },
|
||||
[]byte { 0x00, 0x09, 0x47, 0x63, 0x91, 0x09, 0xBC, 0x10, 0xE1, 0x34, 0xC9 },
|
||||
[]byte { 0x00, 0x0B, 0x40, 0xCB },
|
||||
[]byte { 0x00, 0x0C, 0x41, 0xCB, 0x37 },
|
||||
[]byte { 0x00, 0x0D, 0x43, 0xEF, 0x1E, 0xCB, 0x37 },
|
||||
[]byte { 0x00, 0x0E, 0x47, 0x9C, 0x6E, 0xF6, 0x43, 0xEF, 0x1E, 0xCB, 0x37 },
|
||||
))
|
||||
`)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user