Class ExponentialCornerCases
java.lang.Object
edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator
edu.gvsu.kurmasz.warszawa.listgen.ExponentialCornerCases
- Direct Known Subclasses:
CornerCases
public class ExponentialCornerCases extends IntegerListGenerator
Generate lists of integers that represent values surrounding powers of 2
(using exponents for parameters). (Such values are often "corner cases" when testing
circuits.) This class is similar to
CornerCases
, except the
parameters refer to exponents instead of actual values. For example,
ExponentailCornerCases.getLongArray(5, 7, 1)
produces the same list
as CornerCases.getLongArray(32, 127, 1)
.- Author:
- Zachary Kurmas
-
Constructor Summary
Constructors Constructor Description ExponentialCornerCases()
-
Method Summary
Modifier and Type Method Description long[]
generateLongArray(long start, long stop, long step)
Generate an array oflong
integers containing the values surrounding powers of two.Methods inherited from class edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator
generateIntArray, generateIntList, generateLongList
-
Constructor Details
-
ExponentialCornerCases
public ExponentialCornerCases()
-
-
Method Details
-
generateLongArray
public long[] generateLongArray(long start, long stop, long step)Generate an array oflong
integers containing the values surrounding powers of two. For this class, the user uses exponents to specify the values at which the sequence is to begin and end. For each exponenti
specified (except the first and last), the values(2^i)-1
,2^i
, and(2^i)+1
are included in the output.The first and last exponents behave differently:
(2^{start})-1
is not included. Similarly The last value in the list will be(2^stop)-1
. (In other words,2^stop
, and(2^stop)+1
are not included.) These rules allow the user to use the minimum and maximum widths of the desired values as thestart
andstop
parameters. For example, when testing a 64-bit adder, using 64 as thestop
parameter will specify that the last value is(2^64)-1
: the maximum value that can be represented with 64 bits.Negative parameter values are treated specially: If
start
is-4
, the first value will be-(2^|start|) = -16
(because2^-4
is not an integer).- Specified by:
generateLongArray
in classIntegerListGenerator
- Parameters:
start
- the exponent of the first desired value. (See comment above.) Also,-64
≤start
≤64
(otherwise the resulting values won't be Javalong
s).stop
- the exponent of the last desired value. (See comment above.) Must be>= start
. The value(2^stop)-1
will always appear in the list, even ifstep
would otherwise cause it to be skipped.stop
must be>= start
. Also,-64
≤stop
≤64
(otherwise the resulting values won't be Javalong
s).step
- the value by which the exponent is incremented. Must be>= 1
. (See comment forstop
parameter.)- Returns:
- an array of
long
integers. - Throws:
java.lang.IllegalArgumentException
- if the parameter values specify either (1) a value that is outside the range of a Javalong
, or (2) more values than can be stored in a single array.
-