blob: f3a22a64c37a0cc91325e2c4cddd7d1ea73aa696 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Tests tables whose fields are inlined into the envelope in the wire
// format.
success("TableFieldInlined") {
bindings_allowlist = [go,rust,transformer],
value = TableFieldInlinedStruct {
t: TableFieldInlined {
f: 123,
},
},
bytes = {
v1 = [
num(1):8,
repeat(0xff):8,
num(8):4, num(0):4,
repeat(0xff):8,
num(123):8,
],
v2 = [
num(1):8,
repeat(0xff):8,
num(123):4, num(0):2, num(1):2,
]
}
}
// Tests a table whose handle field is inlined into the envelope in the wire
// format.
success("TableFieldInlinedHandle") {
bindings_allowlist = [go,rust,transformer],
handle_defs = {
#0 = channel(),
},
value = TableFieldInlinedHandleStruct {
t: TableFieldInlinedHandle {
f: #0,
},
},
bytes = {
v1 = [
num(1):8,
repeat(0xff):8,
num(8):4, num(1):4,
repeat(0xff):8,
repeat(0xff):4, padding:4,
],
v2 = [
num(1):8,
repeat(0xff):8,
repeat(0xff):4, num(1):2, num(1):2,
]
},
handles = {
v1, v2 = [#0],
}
}
// Tests tables whose fields are stored out of line in the wire format.
success("TableFieldOutOfLine") {
bindings_allowlist = [go,rust,transformer],
value = TableFieldOutOfLineStruct {
t: TableFieldOutOfLine {
f: 123,
},
},
bytes = {
v1 = [
num(1):8,
repeat(0xff):8,
num(8):4, num(0):4,
repeat(0xff):8,
num(123):8,
],
v2 = [
num(1):8,
repeat(0xff):8,
num(8):4, num(0):2, num(0):2,
num(123):8,
]
}
}
// Tests a table in which a value is inlined into an unknown field.
success("TableFieldUnknownInlined") {
bindings_allowlist = [go,rust,transformer],
value = TableFieldUnknownStruct {
t: TableFieldUnknown {
1: {
bytes = [num(123):4],
}
},
},
bytes = {
v2 = [
num(1):8,
repeat(0xff):8,
num(123):4, num(0):2, num(1):2,
]
}
}
// Tests a table in which a handle value is inlined into an unknown field.
success("TableFieldUnknownInlinedHandle") {
bindings_allowlist = [go,rust,transformer],
handle_defs = {
#0 = channel(),
},
value = TableFieldUnknownStruct {
t: TableFieldUnknown {
1: {
bytes = [repeat(0xff):4],
handles = [#0],
}
},
},
bytes = {
v2 = [
num(1):8,
repeat(0xff):8,
repeat(0xff):4, num(1):2, num(1):2,
]
},
handles = {
v2 = [#0],
}
}
// Tests a table in which a value is stored out of line in an unknown field.
success("TableFieldUnknownOutOfLine") {
bindings_allowlist = [go,rust,transformer],
value = TableFieldUnknownStruct {
t: TableFieldUnknown {
1: {
bytes = [num(123):8],
},
},
},
bytes = {
v1 = [
num(1):8,
repeat(0xff):8,
num(8):4, num(0):4,
repeat(0xff):8,
num(123):8,
],
v2 = [
num(1):8,
repeat(0xff):8,
num(8):4, num(0):2, num(0):2,
num(123):8,
]
}
}
// Tests decode of a value in a table that can be represented inline in the
// envelope but is incorrectly using the out of line representation.
decode_failure("TableOutOfLineEnvelopeWhenInlineRequired") {
bindings_allowlist = [go,transformer],
type = TableFieldInlinedStruct,
bytes = {
v2 = [
num(1):8,
repeat(0xff):8,
num(8):4, num(0):2, num(0):2,
num(123):8,
]
},
err = INVALID_INLINE_BIT_IN_ENVELOPE,
}