xref: /aosp_15_r20/external/emboss/testdata/uint_sizes.emb (revision 99e0aae7469b87d12f0ad23e61142c2d74c1ef70)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15-- Test structs for 8, 16, 32, and 64 bit UInts and enums.
16
17[$default byte_order: "LittleEndian"]
18[(cpp) namespace: "emboss::test"]
19
20
21struct Sizes:
22  0  [+1]  UInt  one_byte
23  1  [+2]  UInt  two_byte
24  3  [+3]  UInt  three_byte
25  6  [+4]  UInt  four_byte
26  10 [+5]  UInt  five_byte
27  15 [+6]  UInt  six_byte
28  21 [+7]  UInt  seven_byte
29  28 [+8]  UInt  eight_byte
30
31
32struct BigEndianSizes:
33  [$default byte_order: "BigEndian"]
34  0  [+1]  UInt  one_byte
35  1  [+2]  UInt  two_byte
36  3  [+3]  UInt  three_byte
37  6  [+4]  UInt  four_byte
38  10 [+5]  UInt  five_byte
39  15 [+6]  UInt  six_byte
40  21 [+7]  UInt  seven_byte
41  28 [+8]  UInt  eight_byte
42
43
44struct AlternatingEndianSizes:
45  [$default byte_order: "BigEndian"]
46  0  [+1]  UInt  one_byte    [byte_order: "BigEndian"]
47  1  [+2]  UInt  two_byte    [byte_order: "LittleEndian"]
48  3  [+3]  UInt  three_byte                                # default to "BigEndian"
49  6  [+4]  UInt  four_byte   [byte_order: "LittleEndian"]
50  10 [+5]  UInt  five_byte                                 # default to "BigEndian"
51  15 [+6]  UInt  six_byte    [byte_order: "LittleEndian"]
52  21 [+7]  UInt  seven_byte  [byte_order: "BigEndian"]
53  28 [+8]  UInt  eight_byte  [byte_order: "LittleEndian"]
54
55
56struct EnumSizes:
57  0  [+1]  Enum  one_byte
58  1  [+2]  Enum  two_byte
59  3  [+3]  Enum  three_byte
60  6  [+4]  Enum  four_byte
61  10 [+5]  Enum  five_byte
62  15 [+6]  Enum  six_byte
63  21 [+7]  Enum  seven_byte
64  28 [+8]  Enum  eight_byte
65
66
67struct ExplicitlySizedEnumSizes:
68  0  [+1]    ExplicitlySizedEnum  one_byte
69  1  [+2]    ExplicitlySizedEnum  two_byte
70  3  [+3]    ExplicitlySizedEnum  three_byte
71  6  [+4]    bits:
72    0 [+28]  ExplicitlySizedEnum  three_and_a_half_byte
73
74
75enum Enum:
76  VALUE1        = 1
77  VALUE10       = 10
78  VALUE100      = 100
79  VALUE1000     = 1000
80  VALUE10000    = 10000
81  VALUE100000   = 100000
82  VALUE1000000  = 1000000
83  VALUE10000000 = 10000000
84
85
86enum ExplicitlySizedEnum:
87  [maximum_bits: 28]
88  VALUE1        = 1
89  VALUE10       = 10
90  VALUE100      = 100
91  VALUE1000     = 1000
92  VALUE10000    = 10000
93  VALUE100000   = 100000
94  VALUE1000000  = 1000000
95  VALUE10000000 = 10000000
96
97
98struct ArraySizes:
99  0  [+2]   UInt:8[2]   one_byte
100  2  [+4]   UInt:16[2]  two_byte
101  6  [+6]   UInt:24[2]  three_byte
102  12 [+8]   UInt:32[2]  four_byte
103  20 [+10]  UInt:40[2]  five_byte
104  30 [+12]  UInt:48[2]  six_byte
105  42 [+14]  UInt:56[2]  seven_byte
106  56 [+16]  UInt:64[2]  eight_byte
107