blob: 72cc41568d81b068814ee52cb5ee5ba670f196ae [file] [log] [blame]
// Copyright 2019 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.
success("UnionWithBoundString") {
value = UnionWithBoundStringStruct {
v: UnionWithBoundString {
boundFiveStr: "abcd",
},
},
bytes = [
tag 8:num(0),
// envelope for string:
size 8:num(4),
ptr 8:num(-1),
data 4:raw('a', 'b', 'c', 'd',), 4:padding,
],
}
encode_failure("UnionWithBoundString_ExceedsBounds") {
value = UnionWithBoundStringStruct {
v: UnionWithBoundString {
boundFiveStr: "abcdef",
},
},
err = STRING_TOO_LONG,
}
success("UnionMigration_SingleVariant") {
value = SingleVariantUnionStruct {
u: SingleVariantUnion {
x: 42,
},
},
bytes = {
old = [
tag 4:num(0), x 4:num(42)
],
v1 = [
// primary object
// TOOD(fxb/39578) Change ordinal to 8:num(1) and remove padding.
ordinal 4:num(1), 4:padding,
num_bytes 4:num(8), num_handles 4:num(0),
present 8:raw(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
// secondary object 1
x 4:num(42), 4:padding,
],
},
// TODO(mkember, bprosnitz): Add languages here as they gain support.
bindings_allowlist = [go],
}
success("UnionSize8Alignment4") {
value = SandwichUnionSize8Alignment4 {
before: 10,
union: UnionSize8Alignment4 {
variant: 4,
},
after: 20,
},
bytes = {
old = [
before 4:num(10), tag 4:num(2),
variant 4:num(4), after 4:num(20)
],
v1 = [
before 4:num(10), 4:padding,
ordinal 8:num(3),
num_bytes 4:num(8), num_handles 4:num(0),
present 8:raw(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
after 4:num(20), 4:padding,
value 4:num(4), 4:padding,
],
},
// TODO(mkember, bprosnitz): Add languages here as they gain support.
bindings_allowlist = [go],
}
success("UnionSize12Alignment4") {
value = SandwichUnionSize12Alignment4 {
before: 10,
union: UnionSize12Alignment4 {
variant: [1, 2, 3, 4, 5, 6],
},
after: 20,
},
bytes = {
old = [
before 4:num(10), tag 4:num(3),
variant 6:raw(0x01, 0x02, 0x03, 0x04, 0x05, 0x06), 2:padding,
after 4:num(20), 4:padding,
],
v1 = [
before 4:num(10), 4:padding,
ordinal 8:num(4),
num_bytes 4:num(8), num_handles 4:num(0),
present 8:raw(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
after 4:num(20), 4:padding,
value 6:raw(0x01, 0x02, 0x03, 0x04, 0x05, 0x06), 2:padding,
],
},
// TODO(mkember, bprosnitz): Add languages here as they gain support.
bindings_allowlist = [go],
}
success("UnionSize24Alignment8") {
value = SandwichUnionSize24Alignment8 {
before: 10,
union: UnionSize24Alignment8 {
variant: StructSize16Alignment8 {
f1: 1,
f2: 2,
},
},
after: 20,
},
bytes = {
old = [
before 4:num(10), 4:padding,
tag 4:num(3), 4:padding,
f1 8:num(1), f2 8:num(2),
after 4:num(20), 4:padding,
],
v1 = [
before 4:num(10), 4:padding,
ordinal 8:num(4),
num_bytes 4:num(16), num_handles 4:num(0),
present 8:raw(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
after 4:num(20), 4:padding,
f1 8:num(1), f2 8:num(2),
],
},
// TODO(mkember, bprosnitz): Add languages here as they gain support.
bindings_allowlist = [go],
}
success("UnionSize36Alignment4") {
value = SandwichUnionSize36Alignment4 {
before: 10,
union: UnionSize36Alignment4 {
variant: [ 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32],
},
after: 20,
},
bytes = {
old = [
before 4:num(10), tag 4:num(3),
32:raw(0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20),
after 4:num(20), 4:padding,
],
v1 = [
before 4:num(10), 4:padding,
ordinal 8:num(4),
num_bytes 4:num(32), num_handles 4:num(0),
present 8:raw(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
after 4:num(20), 4:padding,
32:raw(0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20)
],
},
// TODO(mkember, bprosnitz): Add languages here as they gain support.
bindings_allowlist = [go],
}