-
-
Notifications
You must be signed in to change notification settings - Fork 47
MockUnitInt
Important Note: The library the documentation has moved to www.mockneat.com. The information found on this wiki is quite outdated. Please check the new site.
The MockUnitInt interface extends MockUnit<Integer>.
public interface `MockUnitInt` extends MockUnit<Integer>This means that it "inherits" all the methods from MockUnit<Integer>
The easiest way to obtain a MockUnitInt is to call the ints() method from MockNeat or to call the mapToInt() method.
Methods that are particular to MockUnitInt:
| Method | Description |
|---|---|
arrayPrimitive() |
Generates a MockUnit<int[]> from a MockUnitInt. |
array() |
Generates a MockUnit<Integer[]> from a MockUnitInt. |
intStream() |
Generates a MockUnit<IntStream> from a MockUnitInt. |
The method is used to generate a MockUnit<Integer[]> from a MockUnitInt.
Compared to the array() method from MockUnit<T> there's no reason to specify the type of the array. We know it's Integer[].
Example for creating an array of 100 random Integers, with values between [1000, 2000):
Integer[] array = mock.ints()
.range(1000, 2000)
.array(100)
.val();This method is used to generate a MockUnit<int[]> from a MockUnitInt.
Example for creating a primitive array of 100 random integers, with values between [1000, 2000):
int[] array = mock.ints()
.range(1000, 200)
.arrayPrimitive(100)
.val();Can be used to obtain a more specific IntStream instead of a Stream<Integer>, which normally can be obtain with the stream() from MockUnit<Integer>.
Using the library:
Real World Examples: