org.fest.assertions
Class ArrayAssert<T>

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<T>
          extended by org.fest.assertions.GroupAssert<T>
              extended by org.fest.assertions.ArrayAssert<T>
Type Parameters:
T - the generic type of the arrays.
Direct Known Subclasses:
BooleanArrayAssert, ByteArrayAssert, CharArrayAssert, DoubleArrayAssert, FloatArrayAssert, IntArrayAssert, LongArrayAssert, ObjectArrayAssert, ShortArrayAssert

public abstract class ArrayAssert<T>
extends GroupAssert<T>

Understands assertions for arrays.

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual
 
Constructor Summary
protected ArrayAssert(T actual)
          Creates a new ArrayAssert.
 
Method Summary
protected  int actualGroupSize()
          Returns the size of the actual array.
protected  String actualInBrackets()
          Returns the String representation of the actual array in between brackets ("<" and ">").
protected  void assertContains(List<Object> values)
          Verifies that the actual byte array contains the given values.
protected  void assertContainsOnly(List<Object> values)
          Verifies that the actual array contains the given values only.
protected  void assertExcludes(List<Object> values)
          Verifies that the actual array does not contain the given values.
protected  void assertThatActualHasSize(int expected)
          Verifies that the number of elements in the actual array is equal to the given one.
protected  void assertThatActualIsNotEmpty()
          Verifies that the actual array contains at least on element.
protected  void assertThatActualIsNotNull()
          Verifies that the actual array is not null.
 void isEmpty()
          Verifies that the actual array is empty (not null with zero elements.)
 void isNullOrEmpty()
          Verifies that the actual array is null or empty.
 
Methods inherited from class org.fest.assertions.GroupAssert
hasSize, isNotEmpty
 
Methods inherited from class org.fest.assertions.GenericAssert
as, as, assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, describedAs, describedAs, doesNotSatisfy, is, isEqualTo, isNot, isNotEqualTo, isNotNull, isNotSameAs, isNull, isSameAs, overridingErrorMessage, satisfies
 
Methods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayAssert

protected ArrayAssert(T actual)
Creates a new ArrayAssert.

Parameters:
actual - the target to verify.
Method Detail

actualGroupSize

protected final int actualGroupSize()
Returns the size of the actual array.

Specified by:
actualGroupSize in class GroupAssert<T>
Returns:
the size of the actual array.

assertContains

protected final void assertContains(List<Object> values)
Verifies that the actual byte array contains the given values.

Parameters:
values - the values to look for.
Throws:
AssertionError - if the actual byte array does not contain the given values.

assertContainsOnly

protected final void assertContainsOnly(List<Object> values)
Verifies that the actual array contains the given values only.

Parameters:
values - the values to look for.
Throws:
AssertionError - if the actual array does not contain the given objects, or if the actual array contains elements other than the ones specified.

assertExcludes

protected final void assertExcludes(List<Object> values)
Verifies that the actual array does not contain the given values.

Parameters:
values - the values the array should exclude.
Throws:
AssertionError - if the actual array contains any of the given values.

actualInBrackets

protected final String actualInBrackets()
Returns the String representation of the actual array in between brackets ("<" and ">").

Returns:
the String representation of the actual array in between brackets ("<" and ">").

assertThatActualIsNotNull

protected final void assertThatActualIsNotNull()
Verifies that the actual array is not null.

Throws:
AssertionError - if the actual array is null.

isEmpty

public final void isEmpty()
Verifies that the actual array is empty (not null with zero elements.)

Specified by:
isEmpty in class GroupAssert<T>
Throws:
AssertionError - if the actual array is null or not empty.

isNullOrEmpty

public final void isNullOrEmpty()
Verifies that the actual array is null or empty.

Specified by:
isNullOrEmpty in class GroupAssert<T>
Throws:
AssertionError - if the actual array is not null or not empty.

assertThatActualIsNotEmpty

protected final void assertThatActualIsNotEmpty()
Verifies that the actual array contains at least on element.

Throws:
AssertionError - if the actual array is null.
AssertionError - if the actual array is empty.

assertThatActualHasSize

protected final void assertThatActualHasSize(int expected)
Verifies that the number of elements in the actual array is equal to the given one.

Parameters:
expected - the expected number of elements in the actual array.
Throws:
AssertionError - if the actual array is null.
AssertionError - if the number of elements in the actual array is not equal to the given one.


Copyright © 2007-2010 FEST (Fixtures for Easy Software Testing). All Rights Reserved.