blob: 5c47e6f4188940cc545670e69050609f4aae5c7a [file] [log] [blame] [edit]
success("OneStringOfMaxLengthFive-empty") {
value = OneStringOfMaxLengthFive{
the_string: "",
}
bytes = {
0, 0, 0, 0, 0, 0, 0, 0, // length
255, 255, 255, 255, 255, 255, 255, 255, // alloc present
},
}
success("OneStringOfMaxLengthFive-exactly-five-characters") {
value = OneStringOfMaxLengthFive{
the_string: "hello", // 5 characters
}
bytes = {
5, 0, 0, 0, 0, 0, 0, 0, // length
255, 255, 255, 255, 255, 255, 255, 255, // alloc present
'h', 'e', 'l', 'l', 'o', // "hello"
0, 0, 0, // padding
},
}
success("TableOnlyPrimitives-no-field-is-set") {
value = TableOnlyPrimitives{}
bytes = {
0, 0, 0, 0, 0, 0, 0, 0, // length
255, 255, 255, 255, 255, 255, 255, 255, // alloc present
},
}
success("TableOnlyPrimitives-all-fields-are-set") {
value = TableOnlyPrimitives{
i: -9,
b: true,
u: 314,
}
bytes = {
// not important
},
}
success("UnionOnlyPrimitives-variant-i") {
value = UnionOnlyPrimitives{
i: -9,
}
bytes = {
// not important
},
}
success("UnionWithTableStructString-variant-table") {
value = UnionWithTableStructString{
table: TableOnlyPrimitives{
i: -42,
u: 142,
},
}
bytes = {
// not important
},
}
success("UnionWithTableStructString-variant-struct") {
value = UnionWithTableStructString{
struct: StructOnlyPrimitives{
i: -42,
u: 142,
},
}
bytes = {
// not important
},
}
fails_to_encode("OneStringOfMaxLengthFive-too-long") {
value = OneStringOfMaxLengthFive{
the_string: "bonjour", // 6 characters
}
err = FIDL_STRING_TOO_LONG,
}
fails_to_decode("OneStringOfMaxLengthFive-wrong-length") {
bytes = {
1, 0, 0, 0, 0, 0, 0, 0, // length
255, 255, 255, 255, 255, 255, 255, 255, // alloc present
// one character missing
}
err = FIDL_STRING_INCORRECT_SIZE,
}