/** * Assert that the actual {@code Iterable} has the same size as the other {@code Iterable}. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param other the given {@code Iterable}. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if actual and other {@code Iterable} don't have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Iterable<?> actual, Iterable<?> other) { assertNotNull(info, actual); checkNotNull(info, other); int sizeOfActual = sizeOf(actual); int sizeOfOther = sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(actual, sizeOfActual, sizeOfOther)); }
/** * Asserts that the number of entries in the given {@code Map} has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param map the given {@code Map}. * @param other the group to compare * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the number of entries in the given {@code Map} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Map<?, ?> map, Iterable<?> other) { assertNotNull(info, map); if (other == null) { throw new NullPointerException("The iterable to look for should not be null"); } int sizeOfActual = map.size(); int sizeOfOther = sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(map, sizeOfActual, sizeOfOther)); }
/** * Asserts that the number of entries in the given {@code String} has the same size as the other {@code Iterable}. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param other the group to compare * @throws AssertionError if the given {@code String}. is {@code null}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the number of entries in the given {@code String} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, String actual, Iterable<?> other) { assertNotNull(info, actual); if (other == null) { throw new NullPointerException("The iterable to look for should not be null"); } int sizeOfActual = actual.length(); int sizeOfOther = sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(actual, sizeOfActual, sizeOfOther)); }
void assertHasSameSizeAs(AssertionInfo info, Failures failures, Object array, Iterable<?> other) { assertNotNull(info, array); if (other == null) { throw new NullPointerException("The iterable to look for should not be null"); } int sizeOfActual = sizeOf(array); int sizeOfOther = org.fest.util.Iterables.sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(array, sizeOfActual, sizeOfOther)); }
/** * Asserts that the number of elements in the given {@code Iterable} is equal to the expected one. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the number of elements in the given {@code Iterable} is different than the expected one. */ public void assertHasSize(AssertionInfo info, Iterable<?> actual, int expectedSize) { assertNotNull(info, actual); int sizeOfActual = sizeOf(actual); if (sizeOfActual == expectedSize) { return; } throw failures.failure(info, shouldHaveSize(actual, sizeOfActual, expectedSize)); }
/** * Assert that the actual {@code Iterable} has the same size as the other array. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param other the given array to compare. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if actual {@code Iterable} and other array don't have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Iterable<?> actual, Object[] other) { assertNotNull(info, actual); if (other == null) { throw arrayOfValuesToLookForIsNull(); } int sizeOfActual = sizeOf(actual); int sizeOfOther = other.length; if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(actual, sizeOfActual, sizeOfOther)); }
assertNotNull(info, actual); int sequenceSize = sequence.length; int sizeOfActual = sizeOf(actual); if (sizeOfActual < sequenceSize) { throw actualDoesNotEndWithSequence(info, actual, sequence);
assertNotNull(info, actual); int sequenceSize = sequence.length; if (sizeOf(actual) < sequenceSize) { throw actualDoesNotStartWithSequence(info, actual, sequence);