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