Removed changes to master branch meant for another branch.
This commit is contained in:
@@ -34,22 +34,6 @@ public class Options {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns the same as option with null as an added possibility
|
||||
* @param value The varargs to take a random element from.
|
||||
* @param <E> The type of the elements in the varargs.
|
||||
* @return A randomly selected element from the varargs.
|
||||
*/
|
||||
public <E> E randomlyNull(E... value) {
|
||||
List<E> elements;
|
||||
elements = new ArrayList<>(value.length);
|
||||
for (int i = 0; i < value.length; i++) {
|
||||
elements.add(i, value[i]);
|
||||
}
|
||||
elements.add(value.length, null);
|
||||
return faker.options().option((E[]) elements.toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random element from an array.
|
||||
*
|
||||
|
||||
@@ -35,25 +35,6 @@ public class OptionsTest extends AbstractFakerTest {
|
||||
assertThat(faker.options().option(1, 3, 4, 5), isOneOf(integerOptions));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandomlyNull() {
|
||||
Integer[] int_list = new Integer[] {1,3,4,5,21,13,45};
|
||||
Integer[] int_list_check = new Integer[] {1,3,4,5,21,13,45,null};
|
||||
String[] string_list = new String[] {"hello", "Goodbye", "Hi", "near", "far"};
|
||||
String[] string_list_check = new String[] {"hello", "Goodbye", "Hi", "near", "far", null};
|
||||
for (int i = 0; i < int_list.length; i++) {
|
||||
Integer temp = faker.options().randomlyNull(int_list);
|
||||
assertThat( temp, isOneOf(int_list_check));
|
||||
}
|
||||
|
||||
for (int i = 0; i < string_list.length; i++) {
|
||||
String temp = faker.options().randomlyNull(string_list);
|
||||
assertThat( temp, isOneOf(string_list_check));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionWithEnum() {
|
||||
assertThat(faker.options().option(Day.class), isOneOf(Day.values()));
|
||||
|
||||
Reference in New Issue
Block a user