Skip to content

MockUnitLong

Andrei Ciobanu edited this page Mar 11, 2017 · 3 revisions

MockUnitLong

The MockUnitLong interface extends MockUnit<Long>.

public interface MockUnitLong extends MockUnit<Long>

This means that it "inherits" all the methods from MockUnit<Long>

The easiest way to obtain a MockUnitInt is to call the longs() method from MockNeat or to call the mapToLong() method.

Methods that are particular to MockUnitLong:

Method Description
arrayPrimitive() Generates a MockUnit<long[]> from a MockUnitLong.
array() Generates a MockUnit<Long[]> from a MockUnitLong.
longStream() Generates a MockUnit<LongStream> from a MockUnitLong.

array()

The method is used to generate a MockUnit<Long[]> from a MockUnitLong.

Compared to the array() method from MockUnit<T> there's no reason to specify the type of the array. We know it's Long[].

Example for creating an array of 100 random Longs, with values between [1000, 2000):

Long[] array = mock.longs()
                   .range(1000l, 2000l)
                   .array(100)
                   .val();

arrayPrimitive()

This method is used to generate a MockUnit<long[]> from a MockUnitLong.

Example for creating a primitive array of 100 random longs, with values between [1000l, 2000l):

long[] array = mock.longs()
                   .range(1000, 200)
                   .arrayPrimitive(100)
                   .val();

longStream()

Can be used to obtain a more specific LongStream instead of a Stream<Long>, which normally can be obtain with the stream() from MockUnit<Long>.