Reusable assertions for arrays of booleans. @author Alex Ruiz @author Joel Costigliola @author Mikhail Mazursky @author Nicolas François
| 28 | * @author Nicolas François |
| 29 | */ |
| 30 | public class BooleanArrays { |
| 31 | |
| 32 | private static final BooleanArrays INSTANCE = new BooleanArrays(); |
| 33 | |
| 34 | /** |
| 35 | * Returns the singleton instance of this class. |
| 36 | * |
| 37 | * @return the singleton instance of this class. |
| 38 | */ |
| 39 | public static BooleanArrays instance() { |
| 40 | return INSTANCE; |
| 41 | } |
| 42 | |
| 43 | private final Arrays arrays = Arrays.instance(); |
| 44 | |
| 45 | @VisibleForTesting |
| 46 | Failures failures = Failures.instance(); |
| 47 | |
| 48 | @VisibleForTesting |
| 49 | BooleanArrays() { |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Asserts that the given array is {@code null} or empty. |
| 54 | * |
| 55 | * @param info contains information about the assertion. |
| 56 | * @param actual the given array. |
| 57 | * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. |
| 58 | */ |
| 59 | public void assertNullOrEmpty(AssertionInfo info, boolean[] actual) { |
| 60 | arrays.assertNullOrEmpty(info, failures, actual); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Asserts that the given array is empty. |
| 65 | * |
| 66 | * @param info contains information about the assertion. |
| 67 | * @param actual the given array. |
| 68 | * @throws AssertionError if the given array is {@code null}. |
| 69 | * @throws AssertionError if the given array is not empty. |
| 70 | */ |
| 71 | public void assertEmpty(AssertionInfo info, boolean[] actual) { |
| 72 | arrays.assertEmpty(info, failures, actual); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Asserts that the given array is not empty. |
| 77 | * |
| 78 | * @param info contains information about the assertion. |
| 79 | * @param actual the given array. |
| 80 | * @throws AssertionError if the given array is {@code null}. |
| 81 | * @throws AssertionError if the given array is empty. |
| 82 | */ |
| 83 | public void assertNotEmpty(AssertionInfo info, boolean[] actual) { |
| 84 | arrays.assertNotEmpty(info, failures, actual); |
| 85 | } |
| 86 | |
| 87 | /** |