generate: More fixes for TestGenerateRunDecodeWrongType
This commit is contained in:
parent
087b6b6690
commit
15c5f0b2b8
@ -312,8 +312,8 @@ func TestGenerateRunDecodeWrongType(test *testing.T) {
|
|||||||
reflectValue.Elem().Interface())
|
reflectValue.Elem().Interface())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if n != len(data) - 1 {
|
if n != len(data) {
|
||||||
log.Fatalf("n not equal: %d != %d", n, len(data) - 1)
|
log.Fatalf("n not equal: %d != %d", n, len(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("- MessageInt8")
|
log.Println("- MessageInt8")
|
||||||
@ -341,8 +341,20 @@ func TestGenerateRunDecodeWrongType(test *testing.T) {
|
|||||||
if reflectValue.Len() != 0 {
|
if reflectValue.Len() != 0 {
|
||||||
log.Fatalf("len(destination) not zero: %v", reflectValue.Interface())
|
log.Fatalf("len(destination) not zero: %v", reflectValue.Interface())
|
||||||
}
|
}
|
||||||
if n != len(data) - 1 {
|
if n != len(data) {
|
||||||
log.Fatalf("n not equal: %d != %d", n, len(data) - 1)
|
log.Fatalf("n not equal: %d != %d", n, len(data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
anyCase := func(destination Message) {
|
||||||
|
n, err := destination.Decode(tape.NewDecoder(bytes.NewBuffer(data)),)
|
||||||
|
if err != nil { log.Fatalf("error: %v | n: %d", err, n) }
|
||||||
|
reflectDestination := reflect.ValueOf(destination)
|
||||||
|
reflectValue := reflectDestination.Elem()
|
||||||
|
if reflectValue == reflect.Zero(reflectValue.Type()) {
|
||||||
|
log.Fatalf("len(destination) not zero: %v", reflectValue.Interface())
|
||||||
|
}
|
||||||
|
if n != len(data) {
|
||||||
|
log.Fatalf("n not equal: %d != %d", n, len(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SBA/LBA types should only assign to other SBA/LBA types
|
// SBA/LBA types should only assign to other SBA/LBA types
|
||||||
@ -362,7 +374,7 @@ func TestGenerateRunDecodeWrongType(test *testing.T) {
|
|||||||
log.Println("- MessageTable")
|
log.Println("- MessageTable")
|
||||||
{ var dest = make(MessageTable); arrayCase(&dest) }
|
{ var dest = make(MessageTable); arrayCase(&dest) }
|
||||||
log.Println("- MessageTableDefined")
|
log.Println("- MessageTableDefined")
|
||||||
{ var dest MessageTableDefined; arrayCase(&dest) }
|
{ var dest MessageTableDefined; anyCase(&dest) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user