@@ -334,14 +334,28 @@ class ProtoConverter
334
334
return toHex (maskUnsignedInt (_counter, _numMaskNibbles), HexPrefix::Add);
335
335
}
336
336
337
- static unsigned getArrayLengthFromFuzz (unsigned _fuzz, unsigned _counter = 0 )
337
+ // / Dynamically sized arrays can have a length of at least zero
338
+ // / and at most s_maxArrayLength.
339
+ static unsigned getDynArrayLengthFromFuzz (unsigned _fuzz, unsigned _counter)
338
340
{
339
- return ((_fuzz + _counter) % s_maxArrayLength) + 1 ;
341
+ // Increment modulo value by one in order to meet upper bound
342
+ return (_fuzz + _counter) % (s_maxArrayLength + 1 );
343
+ }
344
+
345
+ // / Statically sized arrays must have a length of at least one
346
+ // / and at most s_maxArrayLength.
347
+ static unsigned getStaticArrayLengthFromFuzz (unsigned _fuzz)
348
+ {
349
+ return _fuzz % s_maxArrayLength + 1 ;
340
350
}
341
351
342
352
static std::pair<bool , unsigned > arrayDimInfoAsPair (ArrayDimensionInfo const & _x)
343
353
{
344
- return std::make_pair (_x.is_static (), getArrayLengthFromFuzz (_x.length ()));
354
+ return (
355
+ _x.is_static () ?
356
+ std::make_pair (true , getStaticArrayLengthFromFuzz (_x.length ())) :
357
+ std::make_pair (false , getDynArrayLengthFromFuzz (_x.length (), 0 ))
358
+ );
345
359
}
346
360
347
361
// / Contains the test program
@@ -360,7 +374,7 @@ class ProtoConverter
360
374
unsigned m_varCounter;
361
375
// / Monotonically increasing return value for error reporting
362
376
unsigned m_returnValue;
363
- static unsigned constexpr s_maxArrayLength = 2 ;
377
+ static unsigned constexpr s_maxArrayLength = 4 ;
364
378
static unsigned constexpr s_maxArrayDimensions = 10 ;
365
379
// / Prefixes for declared and parameterized variable names
366
380
static auto constexpr s_varNamePrefix = " x_" ;
0 commit comments