10111213141516
*/ public class IsTrueTest { @Test public void trueIsTrue() { Assert.assertTrue(new IsTrue().accept(Boolean.TRUE)); }
15161718192021
Assert.assertTrue(new IsTrue().accept(Boolean.TRUE)); } @Test public void falseIsNotTrue() { Assert.assertFalse(new IsTrue().accept(Boolean.FALSE)); }
124125126127128129130131
public static class Any { @Test public void anyMatchesIfAtLeastOnePredicateMatches() { boolean got = Reductions.any(Iterations.iterable(false, true), new IsTrue()); Assert.assertTrue(got); }
130131132133134135136137
Assert.assertTrue(got); } @Test public void anyDoesntMatchIfNoPredicateMatches() { boolean got = Reductions.any(Iterations.iterable(false), new IsTrue()); Assert.assertFalse(got); }
136137138139140141142143
Assert.assertFalse(got); } @Test public void canUseAnyWithIterators() { boolean got = Reductions.any(Iterations.iterator(false), new IsTrue()); Assert.assertFalse(got); }
142143144145146147148149
Assert.assertFalse(got); } @Test public void canUseAnyWithArrays() { boolean got = Reductions.any(new Boolean[]{false}, new IsTrue()); Assert.assertFalse(got); }
149150151152153154155
} @Test(expected = IllegalArgumentException.class) public void cannotCallAnyWithNullIterable() { final Iterable<Boolean> iterable = null; Reductions.any(iterable, new IsTrue()); }
162163164165166167168169
public static class Every { @Test public void everyMatchesIfEveryPredicateMatches() { boolean got = Reductions.every(Iterations.iterable(true, true), new IsTrue()); Assert.assertTrue(got); }
168169170171172173174175
Assert.assertTrue(got); } @Test public void everyDoesntMatchIfOnePredicateDoesntMatch() { boolean got = Reductions.every(Iterations.iterable(true, false), new IsTrue()); Assert.assertFalse(got); }
174175176177178179180181
Assert.assertFalse(got); } @Test public void canUseEveryWithIterators() { boolean got = Reductions.every(Iterations.iterator(false), new IsTrue()); Assert.assertFalse(got); }