org.fest.assertions
Class CharAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<Character>
          extended by org.fest.assertions.CharAssert

public class CharAssert
extends GenericAssert<Character>

Understands assertion methods for Characters and chars. To create a new instance of this class call Assertions.assertThat(Character) or Assertions.assertThat(char).

Author:
Yvonne Wang, David DIDIER, Ansgar Konermann, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual
 
Constructor Summary
protected CharAssert(char actual)
          Creates a new CharAssert.
protected CharAssert(Character actual)
          Creates a new CharAssert.
 
Method Summary
 CharAssert as(Description description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 CharAssert as(String description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 CharAssert describedAs(Description description)
          Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy.
 CharAssert describedAs(String description)
          Alias for GenericAssert.as(String), since "as" is a keyword in Groovy.
 CharAssert doesNotSatisfy(Condition<Character> condition)
          Verifies that the actual Character does not satisfy the given condition.
 CharAssert is(Condition<Character> condition)
          Alias for satisfies(Condition).
 CharAssert isEqualTo(char expected)
          Verifies that the Character value is equal to the given one.
 CharAssert isEqualTo(Character expected)
          Verifies that the actual Character value is equal to the given one.
 CharAssert isGreaterThan(char other)
          Verifies that the Character value is greater than the given one.
 CharAssert isGreaterThanOrEqualTo(char other)
          Verifies that the Character value is greater or equal to the given one.
 CharAssert isLessThan(char other)
          Verifies that the Character value is less than the given one.
 CharAssert isLessThanOrEqualTo(char other)
          Verifies that the Character value is less or equal to the given one.
 CharAssert isLowerCase()
          Verifies that the Character value is an lower-case value.
 CharAssert isNot(Condition<Character> condition)
          Alias for doesNotSatisfy(Condition).
 CharAssert isNotEqualTo(char other)
          Verifies that the Character value is not equal to the given one.
 CharAssert isNotEqualTo(Character other)
          Verifies that the actual Character is not equal to the given one.
 CharAssert isNotNull()
          Verifies that the actual Character is not null.
 CharAssert isNotSameAs(Character other)
          Verifies that the actual Character is not the same object as the given one.
 CharAssert isSameAs(Character expected)
          Verifies that the actual Character is the same object as the given one.
 CharAssert isUpperCase()
          Verifies that the Character value is an upper-case value.
 CharAssert overridingErrorMessage(String message)
          Replaces the default message displayed in case of a failure with the given one.
 CharAssert satisfies(Condition<Character> condition)
          Verifies that the actual Character satisfies the given condition.
 
Methods inherited from class org.fest.assertions.GenericAssert
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull
 
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

CharAssert

protected CharAssert(char actual)
Creates a new CharAssert.

Parameters:
actual - the actual value to verify.

CharAssert

protected CharAssert(Character actual)
Creates a new CharAssert.

Parameters:
actual - the actual value to verify.
Method Detail

as

public CharAssert as(String description)
Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).as("name").isEqualTo("Frodo");
 

Specified by:
as in class GenericAssert<Character>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

public CharAssert describedAs(String description)
Alias for GenericAssert.as(String), since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).describedAs("name").isEqualTo("Frodo");
 

Specified by:
describedAs in class GenericAssert<Character>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

as

public CharAssert as(Description description)
Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
 

Specified by:
as in class GenericAssert<Character>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

public CharAssert describedAs(Description description)
Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
 

Specified by:
describedAs in class GenericAssert<Character>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

isEqualTo

public CharAssert isEqualTo(char expected)
Verifies that the Character value is equal to the given one.

Parameters:
expected - the value to compare the actual one to.
Returns:
this assertion object.
Throws:
AssertionError - if the Character value is not equal to the given one.

isEqualTo

public CharAssert isEqualTo(Character expected)
Verifies that the actual Character value is equal to the given one.

Specified by:
isEqualTo in class GenericAssert<Character>
Parameters:
expected - the given Character value to compare the actual Character to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Character value is not equal to the given one.
Since:
1.3

isNotEqualTo

public CharAssert isNotEqualTo(char other)
Verifies that the Character value is not equal to the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the Character value is equal to the given one.

isNotEqualTo

public CharAssert isNotEqualTo(Character other)
Verifies that the actual Character is not equal to the given one.

Specified by:
isNotEqualTo in class GenericAssert<Character>
Parameters:
other - the given Character to compare the actual Character to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Character value is equal to the given one.
Since:
1.3

isGreaterThan

public CharAssert isGreaterThan(char other)
Verifies that the Character value is greater than the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the Character value is not greater than the given one.

isLessThan

public CharAssert isLessThan(char other)
Verifies that the Character value is less than the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the Character value is not less than the given one.

isGreaterThanOrEqualTo

public CharAssert isGreaterThanOrEqualTo(char other)
Verifies that the Character value is greater or equal to the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the Character value is not greater than or equal to the given one.

isLessThanOrEqualTo

public CharAssert isLessThanOrEqualTo(char other)
Verifies that the Character value is less or equal to the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the Character value is not less than or equal to the given one.

isUpperCase

public CharAssert isUpperCase()
Verifies that the Character value is an upper-case value.

Returns:
this assertion object.
Throws:
AssertionError - if the Character value is not an upper-case value.

isLowerCase

public CharAssert isLowerCase()
Verifies that the Character value is an lower-case value.

Returns:
this assertion object.
Throws:
AssertionError - if the Character value is not an lower-case value.

overridingErrorMessage

public CharAssert overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one.

For example, the following assertion:

 assertThat("Hello").isEqualTo("Bye");
 
will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."

We can replace this message with our own:

 assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");
 
in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".

Specified by:
overridingErrorMessage in class GenericAssert<Character>
Parameters:
message - the given error message, which will replace the default one.
Returns:
this assertion.

satisfies

public CharAssert satisfies(Condition<Character> condition)
Verifies that the actual Character satisfies the given condition.

Specified by:
satisfies in class GenericAssert<Character>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual Character does not satisfy the given condition.
Since:
1.3
See Also:
is(Condition)

doesNotSatisfy

public CharAssert doesNotSatisfy(Condition<Character> condition)
Verifies that the actual Character does not satisfy the given condition.

Specified by:
doesNotSatisfy in class GenericAssert<Character>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual Character does satisfies the given condition.
Since:
1.3
See Also:
isNot(Condition)

is

public CharAssert is(Condition<Character> condition)
Alias for satisfies(Condition).

Specified by:
is in class GenericAssert<Character>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual Character does not satisfy the given condition.
Since:
1.3

isNot

public CharAssert isNot(Condition<Character> condition)
Alias for doesNotSatisfy(Condition).

Specified by:
isNot in class GenericAssert<Character>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual Character does not satisfy the given condition.
Since:
1.3

isNotNull

public CharAssert isNotNull()
Verifies that the actual Character is not null.

Specified by:
isNotNull in class GenericAssert<Character>
Returns:
this assertion object.
Throws:
AssertionError - if the actual Character value is null.
Since:
1.3

isSameAs

public CharAssert isSameAs(Character expected)
Verifies that the actual Character is the same object as the given one.

Specified by:
isSameAs in class GenericAssert<Character>
Parameters:
expected - the given Character to compare the actual Character to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Character value is not the same as the given one.
Since:
1.3

isNotSameAs

public CharAssert isNotSameAs(Character other)
Verifies that the actual Character is not the same object as the given one.

Specified by:
isNotSameAs in class GenericAssert<Character>
Parameters:
other - the given Character to compare the actual BigDecimal to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Character value is the same as the given one.
Since:
1.3


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