public void assertHasSameSizeAs(AssertionInfo info, Object array, Object other) { assertNotNull(info, array); assertIsArray(info, array); assertIsArray(info, other); hasSameSizeAsCheck(info, array, other, sizeOf(array)); }
/** * Asserts that the number of entries in the given {@code Map} has the same size as the other array. * * @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 array 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, Object other) { assertNotNull(info, map); assertIsArray(info, other); hasSameSizeAsCheck(info, map, other, map.size()); }
public void assertHasSameSizeAs(AssertionInfo info, Object array, Object other) { assertNotNull(info, array); assertIsArray(info, array); assertIsArray(info, other); hasSameSizeAsCheck(info, array, other, sizeOf(array)); }
/** * Asserts that the number of entries in the given {@code Map} has the same size as the other array. * * @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 array 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, Object other) { assertNotNull(info, map); assertIsArray(info, other); hasSameSizeAsCheck(info, map, other, map.size()); }
/** * {@inheritDoc} * <p> * Example with byte array: * <pre><code class='java'> // assertions will pass * assertThat(new byte[]{1, 2}).hasSameSizeAs(new byte[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new Byte[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new int[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new String[]{"1", "2"}); * * // assertion will fail * assertThat(new byte[]{ 1, 2 }).hasSameSizeAs(new byte[]{ 1, 2, 3 });</code></pre> */ @Override public SELF hasSameSizeAs(Object other) { assertIsArray(info, other); new Arrays().assertHasSameSizeAs(info, actual, other); return myself; }
/** * Asserts that the number of entries in the given {@code CharSequence} has the same size as the other array. * * @param info contains information about the assertion. * @param actual the given {@code CharSequence}. * @param array the array to compare * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of entries in the given {@code CharSequence} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, CharSequence actual, Object array) { Objects.instance().assertNotNull(info, actual); assertIsArray(info, array); hasSameSizeAsCheck(info, actual, array, actual.length()); }
public void assertContainsAnyOf(AssertionInfo info, Failures failures, Object actual, Object values) { if (commonChecks(info, actual, values)) return; assertIsArray(info, actual); assertIsArray(info, values); List<Object> valuesToSearchFor = asList(values); for (Object element : asList(actual)) { if (iterableContains(valuesToSearchFor, element)) return; } throw failures.failure(info, shouldContainAnyOf(actual, values, comparisonStrategy)); }
/** * 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); assertIsArray(info, other); hasSameSizeAsCheck(info, actual, other, sizeOf(actual)); }
/** * {@inheritDoc} * <p> * Example with byte array: * <pre><code class='java'> // assertions will pass * assertThat(new byte[]{1, 2}).hasSameSizeAs(new byte[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new Byte[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new int[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new String[]{"1", "2"}); * * // assertion will fail * assertThat(new byte[]{ 1, 2 }).hasSameSizeAs(new byte[]{ 1, 2, 3 });</code></pre> */ @Override public SELF hasSameSizeAs(Object other) { assertIsArray(info, other); new Arrays().assertHasSameSizeAs(info, actual, other); return myself; }
/** * Asserts that the number of entries in the given {@code CharSequence} has the same size as the other array. * * @param info contains information about the assertion. * @param actual the given {@code CharSequence}. * @param array the array to compare * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of entries in the given {@code CharSequence} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, CharSequence actual, Object array) { Objects.instance().assertNotNull(info, actual); assertIsArray(info, array); hasSameSizeAsCheck(info, actual, array, actual.length()); }
public void assertContainsAnyOf(AssertionInfo info, Failures failures, Object actual, Object values) { if (commonChecks(info, actual, values)) return; assertIsArray(info, actual); assertIsArray(info, values); List<Object> valuesToSearchFor = asList(values); for (Object element : asList(actual)) { if (iterableContains(valuesToSearchFor, element)) return; } throw failures.failure(info, shouldContainAnyOf(actual, values, comparisonStrategy)); }
/** * 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); assertIsArray(info, other); hasSameSizeAsCheck(info, actual, other, sizeOf(actual)); }
void assertContainsExactly(AssertionInfo info, Failures failures, Object actual, Object values) { if (commonChecks(info, actual, values)) return; assertIsArray(info, actual); assertIsArray(info, values); List<Object> actualAsList = asList(actual); IterableDiff diff = diff(actualAsList, asList(values), comparisonStrategy); if (!diff.differencesFound()) { // actual and values have the same elements but are they in the same order ? int arrayLength = sizeOf(actual); for (int i = 0; i < arrayLength; i++) { Object actualElement = Array.get(actual, i); Object expectedElement = Array.get(values, i); if (!areEqual(actualElement, expectedElement)) throw failures.failure(info, elementsDifferAtIndex(actualElement, expectedElement, i, comparisonStrategy)); } return; } throw failures.failure(info, shouldContainExactly(actual, asList(values), diff.missing, diff.unexpected, comparisonStrategy)); }
void assertContainsExactly(AssertionInfo info, Failures failures, Object actual, Object values) { if (commonChecks(info, actual, values)) return; assertIsArray(info, actual); assertIsArray(info, values); List<Object> actualAsList = asList(actual); IterableDiff diff = diff(actualAsList, asList(values), comparisonStrategy); if (!diff.differencesFound()) { // actual and values have the same elements but are they in the same order ? int arrayLength = sizeOf(actual); for (int i = 0; i < arrayLength; i++) { Object actualElement = Array.get(actual, i); Object expectedElement = Array.get(values, i); if (!areEqual(actualElement, expectedElement)) throw failures.failure(info, elementsDifferAtIndex(actualElement, expectedElement, i, comparisonStrategy)); } return; } throw failures.failure(info, shouldContainExactly(actual, asList(values), diff.missing, diff.unexpected, comparisonStrategy)); }
public void assertHasSameSizeAs(AssertionInfo info, Object array, Object other) { assertNotNull(info, array); assertIsArray(info, array); assertIsArray(info, other); hasSameSizeAsCheck(info, array, other, sizeOf(array)); }
/** * Asserts that the number of entries in the given {@code Map} has the same size as the other array. * * @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 array 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, Object other) { assertNotNull(info, map); assertIsArray(info, other); hasSameSizeAsCheck(info, map, other, map.size()); }
/** * {@inheritDoc} * <p> * Example with byte array: * <pre><code class='java'> * // assertions will pass * assertThat(new byte[]{1, 2}).hasSameSizeAs(new byte[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new Byte[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new int[]{2, 3}); * assertThat(new byte[]{1, 2}).hasSameSizeAs(new String[]{"1", "2"}); * * // assertion will fail * assertThat(new byte[]{ 1, 2 }).hasSameSizeAs(new byte[]{ 1, 2, 3 }); * </code></pre> */ public S hasSameSizeAs(Object other) { assertIsArray(info, other); new Arrays().assertHasSameSizeAs(info, actual, other); return myself; }
/** * Asserts that the number of entries in the given {@code CharSequence} has the same size as the other array. * * @param info contains information about the assertion. * @param actual the given {@code CharSequence}. * @param array the array to compare * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of entries in the given {@code CharSequence} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, CharSequence actual, Object array) { Objects.instance().assertNotNull(info, actual); assertIsArray(info, array); hasSameSizeAsCheck(info, actual, array, actual.length()); }
/** * 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); assertIsArray(info, other); hasSameSizeAsCheck(info, actual, other, sizeOf(actual)); }