@@ -82,12 +82,13 @@ private static void GenerateArgument(
82
82
private static int []
83
83
valueMajorTypes = {
84
84
0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 4 ,
85
- 4 , 5 , 6 , 6 , 7 , 7 , 7 , 7 , 7 , 7 ,
85
+ 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 6 , 6 , 7 , 7 , 7 , 7 , 7 , 7 ,
86
86
};
87
87
88
88
private static int []
89
89
valueMajorTypesHighDepth = {
90
- 0 , 1 , 2 , 3 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 6 , 7 ,
90
+ 0 , 1 , 2 , 3 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ,
91
+ 5 , 5 , 5 , 5 , 5 , 5 , 6 , 7 ,
91
92
};
92
93
93
94
private static int [] valueMajorTypesHighLength = {
@@ -133,6 +134,31 @@ private static void GenerateUtf8(IRandomGenExtended ra, ByteWriter bs, int
133
134
}
134
135
}
135
136
137
+ private void GenerateSmall (IRandomGenExtended r , int depth , ByteWriter bs ) {
138
+ int v = r .GetInt32 (100 );
139
+ if (v < 25 ) {
140
+ GenerateArgument (r , 0 , r .GetInt32 (100 ), bs );
141
+ } else if (v < 35 ) {
142
+ bs .Write (0x41 );
143
+ bs .Write (0x20 );
144
+ } else if (v < 45 ) {
145
+ bs .Write (0x41 );
146
+ bs .Write (0x20 );
147
+ } else if (v < 50 ) {
148
+ bs .Write (0x81 );
149
+ this .GenerateSmall (r , depth + 1 , bs );
150
+ } else if (v < 53 ) {
151
+ bs .Write (0xa2 );
152
+ bs .Write (0xf7 );
153
+ bs .Write (0xf6 );
154
+ this .GenerateSmall (r , depth + 1 , bs );
155
+ bs .Write (0xf5 );
156
+ } else if (v < 80 ) {
157
+ bs .Write (r .GetInt32 (0x40 ));
158
+ } else if (v < 100 ) {
159
+ bs .Write (r .GetInt32 (0x60 ));
160
+ }
161
+ }
136
162
private void Generate (IRandomGenExtended r , int depth , ByteWriter bs ) {
137
163
int majorType = valueMajorTypes [r .GetInt32 (valueMajorTypes .length )];
138
164
if (depth > 6 ) {
@@ -148,9 +174,10 @@ private void Generate(IRandomGenExtended r, int depth, ByteWriter bs) {
148
174
if (r .GetInt32 (50 ) == 0 && depth < 2 ) {
149
175
long v = (long )r .GetInt32 (100000 ) * r .GetInt32 (100000 );
150
176
len = (int )(v / 100000 );
151
- }
152
- if (depth > 6 ) {
177
+ } else if (depth > 6 ) {
153
178
len = r .GetInt32 (100 ) == 0 ? 1 : 0 ;
179
+ } else if (depth > 2 ) {
180
+ len = r .GetInt32 (16 );
154
181
}
155
182
// TODO: Ensure key uniqueness
156
183
if (r .GetInt32 (2 ) == 0 ) {
@@ -186,9 +213,13 @@ private void Generate(IRandomGenExtended r, int depth, ByteWriter bs) {
186
213
if (r .GetInt32 (50 ) == 0 && depth < 2 ) {
187
214
long v = (long )r .GetInt32 (1000 ) * r .GetInt32 (1000 );
188
215
len = (int )(v / 1000 );
216
+ } else if (depth > 6 ) {
217
+ len = r .GetInt32 (100 ) == 0 ? 1 : 0 ;
218
+ } else if (depth > 2 ) {
219
+ len = r .GetInt32 (3 );
189
220
}
190
221
if (depth > 6 ) {
191
- len = r .GetInt32 (100 ) < 50 ? 1 : 0 ;
222
+ len = r .GetInt32 (100 ) < 50 ? 1 : ( r . GetInt32 ( 100 ) < 10 ? 2 : 0 ) ;
192
223
}
193
224
boolean indefiniteLength = r .GetInt32 (2 ) == 0 ;
194
225
if (indefiniteLength ) {
@@ -197,7 +228,11 @@ private void Generate(IRandomGenExtended r, int depth, ByteWriter bs) {
197
228
GenerateArgument (r , majorType , len , bs );
198
229
}
199
230
for (int i = 0 ; i < len ; ++i ) {
200
- this .Generate (r , depth + 1 , bs );
231
+ if (depth > 6 ) {
232
+ this .GenerateSmall (r , depth + 1 , bs );
233
+ } else {
234
+ this .Generate (r , depth + 1 , bs );
235
+ }
201
236
if (majorType == 5 ) {
202
237
this .Generate (r , depth + 1 , bs );
203
238
}
0 commit comments