public void testAsListHashcode() { assertEquals(1, Booleans.asList(EMPTY).hashCode()); assertEquals(Booleans.asList(ARRAY_FALSE).hashCode(), Booleans.asList(ARRAY_FALSE).hashCode()); List<Boolean> reference = Booleans.asList(ARRAY_FALSE); assertEquals(Booleans.asList(ARRAY_FALSE).hashCode(), reference.hashCode()); }
public void testAsListEquals() { assertEquals(Booleans.asList(EMPTY), Collections.emptyList()); assertEquals(Booleans.asList(ARRAY_FALSE), Booleans.asList(ARRAY_FALSE)); assertFalse(Booleans.asList(ARRAY_FALSE).equals(ARRAY_FALSE)); assertFalse(Booleans.asList(ARRAY_FALSE).equals(null)); assertFalse(Booleans.asList(ARRAY_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE))); assertFalse(Booleans.asList(ARRAY_FALSE_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE))); assertEquals(1, Booleans.asList(ARRAY_FALSE_TRUE).lastIndexOf(true)); List<Boolean> reference = Booleans.asList(ARRAY_FALSE); assertEquals(Booleans.asList(ARRAY_FALSE), reference); assertEquals(reference, reference); }
/** * Sets a new named binding. * * @param name name of the binding * @param value a boolean value or a list of boolean values that binds to a given name */ public Builder<V> setBinding(String name, boolean... value) { namedBindings.put(name, toBinding(BooleanValue.MARSHALLER, Booleans.asList(value))); return this; }
/** * Sets a new positional binding. * * @param value a boolean value or a list of boolean values to be set as a new positional * binding */ public Builder<V> addBinding(boolean... value) { positionalBindings.add(toBinding(BooleanValue.MARSHALLER, Booleans.asList(value))); return this; }
public void testAsListLastIndexOf() { assertEquals(-1, Booleans.asList(EMPTY).lastIndexOf((Object) "wrong type")); assertEquals(-1, Booleans.asList(EMPTY).lastIndexOf(true)); assertEquals(-1, Booleans.asList(ARRAY_FALSE).lastIndexOf(true)); assertEquals(1, Booleans.asList(ARRAY_FALSE_TRUE).lastIndexOf(true)); assertEquals(1, Booleans.asList(ARRAY_FALSE_FALSE).lastIndexOf(false)); }
public void testAsListIndexOf() { assertEquals(-1, Booleans.asList(EMPTY).indexOf((Object) "wrong type")); assertEquals(-1, Booleans.asList(EMPTY).indexOf(true)); assertEquals(-1, Booleans.asList(ARRAY_FALSE).indexOf(true)); assertEquals(0, Booleans.asList(ARRAY_FALSE).indexOf(false)); assertEquals(1, Booleans.asList(ARRAY_FALSE_TRUE).indexOf(true)); }
public void testAsListContains() { assertFalse(Booleans.asList(EMPTY).contains((Object) "wrong type")); assertFalse(Booleans.asList(EMPTY).contains(true)); assertFalse(Booleans.asList(ARRAY_FALSE).contains(true)); assertTrue(Booleans.asList(ARRAY_TRUE).contains(true)); assertTrue(Booleans.asList(ARRAY_FALSE_TRUE).contains(false)); assertTrue(Booleans.asList(ARRAY_FALSE_TRUE).contains(true)); }
public void testAsListSet() { List<Boolean> list = Booleans.asList(ARRAY_FALSE); assertFalse(list.set(0, true)); assertTrue(list.set(0, false)); try { list.set(0, null); fail(); } catch (NullPointerException expected) { } try { list.set(1, true); fail(); } catch (IndexOutOfBoundsException expected) { } }
@Test(dataProvider = "inputSequences") public void testNonEmptyInputs(boolean... inputSequence) { List<Boolean> values = Booleans.asList(inputSequence); assertCount(values, 0, distinctCount(values)); }
@Override public Object apply(@NullableDecl Object input) { if (input != null && input.getClass().isArray()) { Iterable<?> iterable; if (input.getClass() == boolean[].class) { iterable = Booleans.asList((boolean[]) input); } else if (input.getClass() == int[].class) { iterable = Ints.asList((int[]) input); } else if (input.getClass() == long[].class) { iterable = Longs.asList((long[]) input); } else if (input.getClass() == short[].class) { iterable = Shorts.asList((short[]) input); } else if (input.getClass() == byte[].class) { iterable = Bytes.asList((byte[]) input); } else if (input.getClass() == double[].class) { iterable = doubleArrayAsString((double[]) input); } else if (input.getClass() == float[].class) { iterable = floatArrayAsString((float[]) input); } else if (input.getClass() == char[].class) { iterable = Chars.asList((char[]) input); } else { iterable = Arrays.asList((Object[]) input); } return Iterables.transform(iterable, STRINGIFY); } return input; } };
public IterableSubject asList() { return checkNoNeedToDisplayBothValues("asList()").that(Booleans.asList(actual())); } }
public void testToArray() { // need explicit type parameter to avoid javac warning!? List<Boolean> none = Arrays.<Boolean>asList(); assertTrue(Arrays.equals(EMPTY, Booleans.toArray(none))); List<Boolean> one = Arrays.asList(false); assertTrue(Arrays.equals(ARRAY_FALSE, Booleans.toArray(one))); boolean[] array = {false, false, true}; List<Boolean> three = Arrays.asList(false, false, true); assertTrue(Arrays.equals(array, Booleans.toArray(three))); assertTrue(Arrays.equals(array, Booleans.toArray(Booleans.asList(array)))); }
public void testToArray_threadSafe() { // Only for booleans, we lengthen VALUES boolean[] VALUES = BooleansTest.VALUES; VALUES = Booleans.concat(VALUES, VALUES); for (int delta : new int[] {+1, 0, -1}) { for (int i = 0; i < VALUES.length; i++) { List<Boolean> list = Booleans.asList(VALUES).subList(0, i); Collection<Boolean> misleadingSize = Helpers.misleadingSizeCollection(delta); misleadingSize.addAll(list); boolean[] arr = Booleans.toArray(misleadingSize); assertEquals(i, arr.length); for (int j = 0; j < i; j++) { assertEquals(VALUES[j], arr[j]); } } } }
private static List<?> primitiveArrayToList(Object obj) { if (obj instanceof boolean[]) { return Booleans.asList((boolean[])obj); } else if (obj instanceof char[]) { return Chars.asList((char[])obj); } else if (obj instanceof byte[]) { return Bytes.asList((byte[])obj); } else if (obj instanceof short[]) { return Shorts.asList((short[])obj); } else if (obj instanceof int[]) { return Ints.asList((int[])obj); } else if (obj instanceof long[]) { return Longs.asList((long[])obj); } else if (obj instanceof float[]) { return Floats.asList((float[])obj); } else if (obj instanceof double[]) { return Doubles.asList((double[])obj); } return Collections.<Object>emptyList(); }
switch (type) { case BOOLEAN_TYPE: value.setBoolVal(new TBoolColumn(Booleans.asList(Arrays.copyOfRange(boolVars, 0, size)), nullMasks)); break;
assertThat(rs.getBooleanArray(8)).isEqualTo(boolArray); assertThat(rs.getBooleanArray("boolArray")).isEqualTo(boolArray); assertThat(rs.getBooleanList(8)).isEqualTo(Booleans.asList(boolArray)); assertThat(rs.getBooleanList("boolArray")).isEqualTo(Booleans.asList(boolArray)); assertThat(rs.getLongArray(9)).isEqualTo(longArray); assertThat(rs.getLongArray("longArray")).isEqualTo(longArray);
public void testAsListEquals() { assertEquals(Booleans.asList(EMPTY), Collections.emptyList()); assertEquals(Booleans.asList(ARRAY_FALSE), Booleans.asList(ARRAY_FALSE)); assertFalse(Booleans.asList(ARRAY_FALSE).equals(ARRAY_FALSE)); assertFalse(Booleans.asList(ARRAY_FALSE).equals(null)); assertFalse(Booleans.asList(ARRAY_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE))); assertFalse(Booleans.asList(ARRAY_FALSE_FALSE).equals(Booleans.asList(ARRAY_FALSE_TRUE))); assertEquals(1, Booleans.asList(ARRAY_FALSE_TRUE).lastIndexOf(true)); List<Boolean> reference = Booleans.asList(ARRAY_FALSE); assertEquals(Booleans.asList(ARRAY_FALSE), reference); assertEquals(reference, reference); }