| // 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 = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| |
| // secondary object 1: union |
| num(4):8, repeat(0xff):8, // boundFiveStr size, present |
| |
| // secondary object 2: boundFiveStr |
| 'a', 'b', 'c', 'd', padding:4, |
| ], |
| }, |
| } |
| |
| encode_failure("UnionWithBoundString_ExceedsBounds") { |
| value = UnionWithBoundStringStruct{ |
| v: UnionWithBoundString{ |
| boundFiveStr: "abcdef", |
| }, |
| }, |
| err = STRING_TOO_LONG, |
| } |
| |
| success("UnionMigration_SingleVariant") { |
| value = SingleVariantUnionStruct{ |
| u: SingleVariantUnion{ |
| x: 42, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(42):4, num(0):2, num(1):2, // envelope |
| ], |
| }, |
| } |
| |
| success("UnionMigration_Uint8Union_1") { |
| value = Uint8UnionStruct{ |
| u: Uint8Union{ |
| uint8_value: 42, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(42):4, num(0):2, num(1):2, // envelope |
| ], |
| }, |
| } |
| |
| success("UnionMigration_Uint8Union_2") { |
| value = Uint8UnionStruct{ |
| u: Uint8Union{ |
| empty_struct: EmptyStruct{}, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(2):8, // ordinal |
| num(0):4, num(0):2, num(1):2, // envelope |
| ], |
| }, |
| } |
| |
| success("ReverseOrdinalUnion") { |
| value = ReverseOrdinalUnionStruct{ |
| u: ReverseOrdinalUnion{ |
| x: 42, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(4):8, // ordinal |
| num(8):4, num(0):2, num(0):2, // envelope |
| |
| // secondary object 1: x |
| num(42):8, |
| ], |
| }, |
| } |
| |
| // ======================== UNKNOWN VARIANT TESTS ========================== |
| |
| success("FlexibleUnionUnknownValueStored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of FlexibleUnionUnknownValue |
| // decode_success and encode_failure tests. |
| bindings_allowlist = [dart, go], |
| value = TestFlexibleXUnionInStruct{ |
| xu: SampleXUnion{ |
| 1234: { |
| // padding must be included in the raw bytes |
| bytes = [repeat(0xab):20, padding:4], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| } |
| |
| decode_success("FlexibleUnionUnknownValue") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = TestFlexibleXUnionInStruct{ |
| xu: SampleXUnion{ |
| 1234: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| } |
| |
| encode_failure("FlexibleUnionUnknownValue") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = TestFlexibleXUnionInStruct{ |
| xu: decode({ |
| type = SampleXUnion, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| }), |
| }, |
| err = FLEXIBLE_UNION_UNKNOWN_FIELD, |
| } |
| |
| success("FlexibleResourceUnionUnknownValueStored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // FlexibleResourceUnionUnknownValue decode_success and encode_failure tests. |
| bindings_allowlist = [dart, go], |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 1234: { |
| // padding must be included in the raw bytes |
| bytes = [repeat(0xab):20, padding:4], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| } |
| |
| decode_success("FlexibleResourceUnionUnknownValue") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 1234: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| } |
| |
| encode_failure("FlexibleResourceUnionUnknownValue") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: decode({ |
| type = SampleResourceXUnion, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| }), |
| }, |
| err = FLEXIBLE_UNION_UNKNOWN_FIELD, |
| } |
| |
| success("FlexibleResourceUnionUnknownValueWithHandlesStored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // FlexibleResourceUnionUnknownValueWithHandles decode_success and |
| // encode_failure tests. |
| bindings_allowlist = [dart, go], |
| handle_defs = { |
| #0 = event(), |
| #1 = event(), |
| #2 = channel(), |
| #3 = channel(), |
| }, |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 1234: { |
| // padding must be included in the raw bytes |
| bytes = [repeat(0xab):20, padding:4], |
| handles = [#0, #1, #2, #3], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(4):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| handles = { |
| v2 = [ |
| #0, #1, #2, #3, |
| ], |
| }, |
| } |
| |
| decode_success("FlexibleResourceUnionUnknownValueWithHandles") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| handle_defs = { |
| #0 = event(), |
| #1 = event(), |
| #2 = channel(), |
| #3 = channel(), |
| }, |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 1234: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(4):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| handles = { |
| v2 = [ |
| #0, #1, #2, #3, |
| ], |
| }, |
| } |
| |
| encode_failure("FlexibleResourceUnionUnknownValueWithHandles") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| handle_defs = { |
| #0 = event(), |
| #1 = event(), |
| #2 = channel(), |
| #3 = channel(), |
| }, |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: decode({ |
| type = SampleResourceXUnion, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(4):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| handles = { |
| v2 = [ |
| #0, #1, #2, #3, |
| ], |
| }, |
| }), |
| }, |
| err = FLEXIBLE_UNION_UNKNOWN_FIELD, |
| } |
| |
| decode_failure("StrictUnionUnknownValue") { |
| type = TestStrictXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = STRICT_UNION_UNKNOWN_FIELD, |
| } |
| |
| decode_failure("StrictUnionUnknownValueWithHandles") { |
| handle_defs = { |
| #0 = event(), |
| #1 = event(), |
| #2 = channel(), |
| #3 = channel(), |
| }, |
| type = TestStrictXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(4):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| handles = { |
| v2 = [ |
| #0, #1, #2, #3, |
| ], |
| }, |
| err = STRICT_UNION_UNKNOWN_FIELD, |
| } |
| |
| decode_failure("FlexibleUnionUnknownValueWithHandles") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // FlexibleUnionUnknownValueWithHandlesCloseHandles decode_success test. |
| bindings_allowlist = [dart, go], |
| handle_defs = { |
| #0 = event(), |
| #1 = event(), |
| #2 = channel(), |
| #3 = channel(), |
| }, |
| type = TestFlexibleXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(4):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| handles = { |
| v2 = [ |
| #0, #1, #2, #3, |
| ], |
| }, |
| err = NON_RESOURCE_UNKNOWN_HANDLES, |
| } |
| |
| decode_success("FlexibleUnionUnknownValueWithHandlesCloseHandles") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| handle_defs = { |
| #0 = event(), |
| #1 = event(), |
| #2 = channel(), |
| #3 = channel(), |
| }, |
| value = TestFlexibleXUnionInStruct{ |
| xu: SampleXUnion{ |
| 1234: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| num(1234):8, // unknown ordinal |
| num(24):4, num(4):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| handles = { |
| v2 = [ |
| #0, #1, #2, #3, |
| ], |
| }, |
| } |
| |
| encode_failure("StrictUnionUnknownValue") { |
| // Currently no bindings allow constructing a strict union with an unknown variant |
| bindings_allowlist = [], |
| value = TestStrictXUnionInStruct{ |
| xu: SampleStrictXUnion{ |
| 1234: { |
| // padding must be included in the raw bytes |
| bytes = [repeat(0xab):20, padding:4], |
| }, |
| }, |
| }, |
| err = STRICT_UNION_UNKNOWN_FIELD, |
| } |
| |
| decode_failure("FlexibleValueUnionUnknownBytesNonMultipleOf8") { |
| type = TestFlexibleXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(123):8, // ordinal (unknown) |
| num(20):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = INVALID_NUM_BYTES_IN_ENVELOPE, |
| } |
| |
| decode_failure("FlexibleResourceUnionUnknownBytesNonMultipleOf8") { |
| type = TestFlexibleResourceXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(123):8, // ordinal (unknown) |
| num(20):4, num(0):2, num(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = INVALID_NUM_BYTES_IN_ENVELOPE, |
| } |
| |
| success("UnionEnvelopeInlining_SmallValue_Inlined") { |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| small: 100, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(100):4, num(0):2, num(1):2, // inlined envelope |
| ], |
| }, |
| } |
| |
| success("UnionEnvelopeInlining_LargeValue_Outlined") { |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| large: 100, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(2):8, // ordinal |
| num(8):4, num(0):2, num(0):2, // present |
| |
| // secondary object |
| num(100):8, |
| ], |
| }, |
| } |
| |
| decode_failure("UnionEnvelopeInlining_SmallValue_BadInlineMarkerLower") { |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(100):4, num(0):2, 0xff, 0x00, // inlined envelope |
| ], |
| }, |
| err = INVALID_INLINE_MARKER_IN_ENVELOPE, |
| } |
| |
| decode_failure("UnionEnvelopeInlining_SmallValue_BadInlineMarkerUpper") { |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(100):4, num(0):2, 0x01, 0xee, // inlined envelope |
| ], |
| }, |
| err = INVALID_INLINE_MARKER_IN_ENVELOPE, |
| } |
| |
| decode_failure("UnionEnvelopeInlining_LargeValue_BadOutlinedMarker") { |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(2):8, // ordinal |
| |
| // 0xfe, 0xff is an inline marker with only the inline bit unset. |
| num(8):4, num(0):2, 0xfe, 0xff, |
| |
| // secondary object |
| num(100):8, |
| ], |
| }, |
| err = INVALID_INLINE_MARKER_IN_ENVELOPE, |
| } |
| |
| success("UnionEnvelopeInlining_HandleValue_Inlined") { |
| handle_defs = { |
| #0 = event(), |
| }, |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| handle: #0, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(3):8, // ordinal |
| repeat(0xff):4, num(1):2, num(1):2, // inlined envelope |
| ], |
| }, |
| handles = { |
| v2 = [#0], |
| }, |
| } |
| |
| success("UnionEnvelopeInlining_UnknownSmallValue_Inlined_Stored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // UnionEnvelopeInlining_UnknownSmallValue_Inlined decode_success test. |
| bindings_allowlist = [go], |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| 10: { |
| bytes = [num(100):4], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(10):8, // ordinal |
| num(100):4, num(0):2, num(1):2, // inlined envelope |
| ], |
| }, |
| } |
| |
| decode_success("UnionEnvelopeInlining_UnknownSmallValue_Inlined") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| 10: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(10):8, // ordinal |
| num(100):4, num(0):2, num(1):2, // inlined envelope |
| ], |
| }, |
| } |
| |
| success("UnionEnvelopeInlining_UnknownLargeValue_Outlined_Stored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // UnionEnvelopeInlining_UnknownLargeValue_Outlined decode_success test. |
| bindings_allowlist = [go], |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| 10: { |
| bytes = [num(100):8], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(10):8, // ordinal |
| num(8):4, num(0):2, num(0):2, // present |
| |
| // secondary object |
| num(100):8, |
| ], |
| }, |
| } |
| |
| decode_success("UnionEnvelopeInlining_UnknownLargeValue_Outlined") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| 10: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(10):8, // ordinal |
| num(8):4, num(0):2, num(0):2, // present |
| |
| // secondary object |
| num(100):8, |
| ], |
| }, |
| } |
| |
| success("UnionEnvelopeInlining_UnknownHandleValue_Inlined_Stored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // UnionEnvelopeInlining_UnknownHandleValue_Inlined decode_success test. |
| bindings_allowlist = [go], |
| handle_defs = { |
| #0 = event(), |
| }, |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| 10: { |
| bytes = [repeat(0xff):4], |
| handles = [#0], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(10):8, // ordinal |
| repeat(0xff):4, num(1):2, num(1):2, // inlined envelope |
| ], |
| }, |
| handles = { |
| v2 = [#0], |
| }, |
| } |
| |
| decode_success("UnionEnvelopeInlining_UnknownHandleValue_Inlined") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| handle_defs = { |
| #0 = event(), |
| }, |
| value = EnvelopeInliningTestUnionStruct{ |
| u: EnvelopeInliningTestUnion{ |
| 10: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(10):8, // ordinal |
| repeat(0xff):4, num(1):2, num(1):2, // inlined envelope |
| ], |
| }, |
| handles = { |
| v2 = [#0], |
| }, |
| } |
| |
| // Tests decode of a value in a union that can be represented inline in the |
| // envelope but is incorrectly using the out of line representation. |
| decode_failure("UnionOutOfLineEnvelopeWhenInlineRequired") { |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(8):4, num(0):2, num(0):2, // present |
| |
| // secondary object |
| num(100):8, |
| ], |
| }, |
| err = INVALID_INLINE_BIT_IN_ENVELOPE, |
| } |
| |
| // Tests decode of a value in a union that can be represented out of line in |
| // the envelope but is incorrectly using the inline representation. |
| decode_failure("UnionInlineEnvelopeWhenOutOfLineRequired") { |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(2):8, // ordinal |
| num(8):4, num(0):2, num(1):2, // present |
| ], |
| }, |
| err = INVALID_INLINE_BIT_IN_ENVELOPE, |
| } |
| |
| encode_failure("RequiredFlexibleValueUnionZeroOrdinalNoPayloadOld") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // RequiredFlexibleValueUnionZeroOrdinalNoPayload. |
| bindings_allowlist = [dart, go], |
| value = TestFlexibleXUnionInStruct{ |
| xu: SampleXUnion{ |
| 0: { |
| bytes = [], |
| }, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredFlexibleValueUnionZeroOrdinalNoPayload") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = TestFlexibleXUnionInStruct{ |
| xu: SampleXUnion{ |
| 0: null, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredFlexibleValueUnionZeroOrdinalWithPayload") { |
| // TODO(https://fxbug.dev/42166276): Remove this test once no binding stores unknown |
| // data (it's only expressible when you can store unknown data). |
| bindings_allowlist = [dart, go], |
| value = TestFlexibleXUnionInStruct{ |
| xu: SampleXUnion{ |
| 0: { |
| bytes = [repeat(0xab):20, padding:4], |
| }, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredFlexibleResourceUnionZeroOrdinalNoPayloadOld") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // RequiredFlexibleResourceUnionZeroOrdinalNoPayload. |
| bindings_allowlist = [dart, go], |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 0: { |
| bytes = [], |
| }, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredFlexibleResourceUnionZeroOrdinalNoPayload") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 0: null, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredFlexibleResourceUnionZeroOrdinalWithPayload") { |
| // TODO(https://fxbug.dev/42166276): Remove this test once no binding stores unknown |
| // data (it's only expressible when you can store unknown data). |
| bindings_allowlist = [dart, go], |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 0: { |
| bytes = [repeat(0xab):20, padding:4], |
| }, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("OptionalFlexibleValueUnionZeroOrdinalWithPayload") { |
| // TODO(https://fxbug.dev/42166276): Remove this test once no binding stores unknown |
| // data (it's only expressible when you can store unknown data). |
| bindings_allowlist = [dart, go], |
| value = TestOptionalFlexibleXUnionInStruct{ |
| xu: SampleXUnion{ |
| 0: { |
| bytes = [repeat(0xab):20, padding:4], |
| }, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("OptionalFlexibleResourceUnionZeroOrdinalWithPayload") { |
| // TODO(https://fxbug.dev/42166276): Remove this test once no binding stores unknown |
| // data (it's only expressible when you can store unknown data). |
| bindings_allowlist = [dart, go], |
| value = TestOptionalFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{ |
| 0: { |
| bytes = [repeat(0xab):20, padding:4], |
| }, |
| }, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| decode_failure("RequiredStrictValueUnionZeroOrdinalNoPayload") { |
| type = TestStrictXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| err = NON_NULLABLE_TYPE_WITH_NULL_VALUE, |
| } |
| |
| decode_failure("RequiredStrictValueUnionZeroOrdinalWithPayload") { |
| type = TestStrictXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| decode_failure("RequiredStrictResourceUnionZeroOrdinalNoPayload") { |
| type = TestStrictResourceXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| err = NON_NULLABLE_TYPE_WITH_NULL_VALUE, |
| } |
| |
| decode_failure("RequiredStrictResourceUnionZeroOrdinalWithPayload") { |
| type = TestStrictResourceXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| decode_failure("RequiredFlexibleValueUnionZeroOrdinalNoPayload") { |
| type = TestFlexibleXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| err = NON_NULLABLE_TYPE_WITH_NULL_VALUE, |
| } |
| |
| decode_failure("RequiredFlexibleValueUnionZeroOrdinalWithPayload") { |
| type = TestFlexibleXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| decode_failure("RequiredFlexibleResourceUnionZeroOrdinalNoPayload") { |
| type = TestFlexibleResourceXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| err = NON_NULLABLE_TYPE_WITH_NULL_VALUE, |
| } |
| |
| decode_failure("RequiredFlexibleResourceUnionZeroOrdinalWithPayload") { |
| type = TestFlexibleResourceXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| success("OptionalStrictValueUnionZeroOrdinalNoPayload") { |
| value = TestOptionalStrictXUnionInStruct{ |
| xu: null, |
| }, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| } |
| |
| decode_failure("OptionalStrictValueUnionZeroOrdinalWithPayload") { |
| type = TestOptionalStrictXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| success("OptionalStrictResourceUnionZeroOrdinalNoPayload") { |
| value = TestOptionalStrictResourceXUnionInStruct{ |
| xu: null, |
| }, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| } |
| |
| decode_failure("OptionalStrictResourceUnionZeroOrdinalWithPayload") { |
| type = TestOptionalStrictResourceXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| success("OptionalFlexibleValueUnionZeroOrdinalNoPayload") { |
| value = TestOptionalFlexibleXUnionInStruct{ |
| xu: null, |
| }, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| } |
| |
| decode_failure("OptionalFlexibleValueUnionZeroOrdinalWithPayload") { |
| type = TestOptionalFlexibleXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| success("OptionalFlexibleResourceUnionZeroOrdinalNoPayload") { |
| value = TestOptionalFlexibleResourceXUnionInStruct{ |
| xu: null, |
| }, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(0):4, num(0):2, repeat(0):2, // envelope |
| ], |
| }, |
| } |
| |
| decode_failure("OptionalFlexibleResourceUnionZeroOrdinalWithPayload") { |
| type = TestOptionalFlexibleResourceXUnionInStruct, |
| bytes = { |
| v2 = [ |
| num(0):8, // zero ordinal |
| num(24):4, num(0):2, repeat(0):2, // envelope |
| repeat(0xab):20, padding:4, // unknown bytes |
| ], |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredStrictValueUnionDefaultInitialized") { |
| bindings_allowlist = [go, llcpp, hlcpp], |
| value = TestStrictXUnionInStruct{ |
| xu: SampleStrictXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredStrictResourceUnionDefaultInitialized") { |
| bindings_allowlist = [go, llcpp, hlcpp], |
| value = TestStrictResourceXUnionInStruct{ |
| xu: SampleStrictResourceXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredFlexibleValueUnionDefaultInitialized") { |
| bindings_allowlist = [go, llcpp, hlcpp], |
| value = TestFlexibleXUnionInStruct{ |
| xu: SampleXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("RequiredFlexibleResourceUnionDefaultInitialized") { |
| bindings_allowlist = [go, llcpp, hlcpp], |
| value = TestFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("OptionalStrictValueUnionDefaultInitialized") { |
| // TODO(https://fxbug.dev/42158133): Enable in HLCPP and LLCPP. |
| bindings_allowlist = [go], |
| value = TestOptionalStrictXUnionInStruct{ |
| xu: SampleStrictXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("OptionalStrictResourceUnionDefaultInitialized") { |
| // TODO(https://fxbug.dev/42158133): Enable in HLCPP and LLCPP. |
| bindings_allowlist = [go], |
| value = TestOptionalStrictResourceXUnionInStruct{ |
| xu: SampleStrictResourceXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("OptionalFlexibleValueUnionDefaultInitialized") { |
| // TODO(https://fxbug.dev/42158133): Enable in HLCPP, LLCPP. |
| bindings_allowlist = [go], |
| value = TestOptionalFlexibleXUnionInStruct{ |
| xu: SampleXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| encode_failure("OptionalFlexibleResourceUnionDefaultInitialized") { |
| // TODO(https://fxbug.dev/42158133): Enable in HLCPP, LLCPP. |
| bindings_allowlist = [go], |
| value = TestOptionalFlexibleResourceXUnionInStruct{ |
| xu: SampleResourceXUnion{}, |
| }, |
| err = UNION_FIELD_NOT_SET, |
| } |
| |
| decode_failure("EnvelopeByteCountExceedsMessageByteCount") { |
| // TODO(https://fxbug.dev/42169965) Fix in Rust. |
| // TODO(https://fxbug.dev/42169966) Fix in Dart. |
| bindings_denylist = [rust, dart], |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| num(100):8, // unknown |
| num(8):4, num(0):2, repeat(0):2, |
| ], |
| }, |
| err = ENVELOPE_BYTES_EXCEED_MESSAGE_LENGTH, |
| } |
| |
| decode_failure("EnvelopeHandleCountExceedsMessageHandleCount") { |
| // TODO(https://fxbug.dev/42169966) Fix in Dart. |
| // TODO(https://fxbug.dev/42051692) Fix in Go. |
| bindings_denylist = [dart, go], |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| num(1):8, // small |
| num(0):4, num(1):2, num(1):2, |
| ], |
| }, |
| err = ENVELOPE_HANDLES_EXCEED_MESSAGE_LENGTH, |
| } |
| |
| decode_failure("EnvelopeHandleCountExceedsMessageHandleCountUnknown") { |
| // TODO(https://fxbug.dev/42169965) Fix in Rust. |
| // TODO(https://fxbug.dev/42169966) Fix in Dart. |
| bindings_denylist = [rust, dart], |
| type = EnvelopeInliningTestUnionStruct, |
| bytes = { |
| v2 = [ |
| num(100):8, // unknown |
| num(0):4, num(1):2, repeat(0):2, |
| ], |
| }, |
| err = ENVELOPE_HANDLES_EXCEED_MESSAGE_LENGTH, |
| } |
| |
| decode_success("EmptyFlexibleUnionDecodesUnknownSmallValueStored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // EmptyFlexibleUnionDecodesUnknownSmallValue. |
| bindings_allowlist = [dart, go], |
| value = StructOfEmptyFlexibleUnion{ |
| empty: EmptyFlexibleUnion{ |
| 1: { |
| // padding must be included in the raw bytes |
| bytes = [0xff, padding:3], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| 0xff, padding:3, num(0):2, num(1):2, // inlined envelope |
| ], |
| }, |
| } |
| |
| decode_success("EmptyFlexibleUnionDecodesUnknownSmallValue") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = StructOfEmptyFlexibleUnion{ |
| empty: EmptyFlexibleUnion{ |
| 1: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| 0xff, padding:3, num(0):2, num(1):2, // inlined envelope |
| ], |
| }, |
| } |
| |
| decode_success("EmptyFlexibleUnionDecodesUnknownLargeValueStored") { |
| // TODO(https://fxbug.dev/42166276): Remove in favor of |
| // EmptyFlexibleUnionDecodesUnknownLargeValue. |
| bindings_allowlist = [dart, go], |
| value = StructOfEmptyFlexibleUnion{ |
| empty: EmptyFlexibleUnion{ |
| 1: { |
| // padding must be included in the raw bytes |
| bytes = [repeat(0xab):8], |
| }, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(8):4, num(0):4, // envelope |
| |
| // secondary object |
| repeat(0xab):8, |
| ], |
| }, |
| } |
| |
| decode_success("EmptyFlexibleUnionDecodesUnknownLargeValue") { |
| // TODO(https://fxbug.dev/42166276): Drop unknown data in all bindings. |
| bindings_allowlist = [rust], |
| value = StructOfEmptyFlexibleUnion{ |
| empty: EmptyFlexibleUnion{ |
| 1: null, |
| }, |
| }, |
| bytes = { |
| v2 = [ |
| // primary object |
| num(1):8, // ordinal |
| num(8):4, num(0):4, // envelope |
| |
| // secondary object |
| repeat(0xab):8, |
| ], |
| }, |
| } |