Package org.fest.assertions
Class FloatAssert
- All Implemented Interfaces:
NumberAssert
Understands assertion methods for
Floats and floats. To create a new instance of this class call
Assertions.assertThat(Float) or Assertions.assertThat(float).-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.fest.assertions.GenericAssert
actual -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFloatAssert(float actual) Creates a new.FloatAssertprotectedFloatAssert(Float actual) Creates a new.FloatAssert -
Method Summary
Modifier and TypeMethodDescriptionSets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionErroras(Description description) Sets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionErrorprivate intcompareTo(float other) static FloatAssert.Deltadelta(float d) Deprecated.use methodinstead.Delta.delta(double)describedAs(String description) Alias for, since "as" is a keyword in Groovy.GenericAssert.as(String)describedAs(Description description) Alias for, since "as" is a keyword in Groovy.GenericAssert.as(Description)doesNotSatisfy(Condition<Float> condition) Verifies that the actualdoes not satisfy the given condition.FloatAlias for.satisfies(Condition)isEqualTo(float expected) Verifies that the actualFloatis equal to the given one.private FloatAssertisEqualTo(float expected, float deltaValue) Verifies that the actualFloatis equal to the given one, within a positive delta.isEqualTo(float expected, FloatAssert.Delta delta) Deprecated.use methodinstead.isEqualTo(float, org.fest.assertions.Delta)Verifies that the actualFloatis equal to the given one.private FloatAssertVerifies that the actualFloatis equal to the given one, within a positive delta.isGreaterThan(float other) Verifies that the actualFloatis greater than the given one.isGreaterThanOrEqualTo(float other) Verifies that the actualFloatis greater or equal to the given one.isLessThan(float other) Verifies that the actualFloatis less than the given one.isLessThanOrEqualTo(float other) Verifies that the actualFloatis less or equal to the given one.isNaN()Verifies that the actualFloatis equal to.Float.NaNVerifies that the actualFloatis negative.Alias for.doesNotSatisfy(Condition)isNotEqualTo(float other) Verifies that the actualFloatis not equal to the given one.isNotEqualTo(Float other) Verifies that the actualis not equal to the given one.FloatVerifies that the actualis notFloatnull.isNotSameAs(Float other) Verifies that the actualis not the same object as the given one.FloatVerifies that the actualFloatis positive.Verifies that the actualis the same object as the given one.FloatisZero()Verifies that the actualFloatis equal to zero.overridingErrorMessage(String message) Replaces the default message displayed in case of a failure with the given one.Verifies that the actualsatisfies the given condition.FloatMethods inherited from class org.fest.assertions.GenericAssert
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNullMethods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
-
Field Details
-
ZERO
private static final float ZERO- See Also:
-
-
Constructor Details
-
FloatAssert
protected FloatAssert(float actual) Creates a new.FloatAssert- Parameters:
actual- the actual value to verify.
-
FloatAssert
Creates a new.FloatAssert- Parameters:
actual- the actual value to verify.
-
-
Method Details
-
as
Sets the description of the actual value, to be used in as message of anythrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionErrorFor example:
assertThat(val).as("name").isEqualTo("Frodo");- Specified by:
asin classGenericAssert<Float>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
describedAs
Alias for, 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.GenericAssert.as(String)For example:
assertThat(val).describedAs("name").isEqualTo("Frodo");- Specified by:
describedAsin classGenericAssert<Float>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
as
Sets the description of the actual value, to be used in as message of anythrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionErrorFor example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");- Specified by:
asin classGenericAssert<Float>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
describedAs
Alias for, 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.GenericAssert.as(Description)For example:
assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");- Specified by:
describedAsin classGenericAssert<Float>- Parameters:
description- the description of the actual value.- Returns:
- this assertion object.
-
isEqualTo
Verifies that the actualFloatis equal to the given one.- Parameters:
expected- the value to compare the actual one to.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not equal to the given one.
-
isEqualTo
Verifies that the actualFloatis equal to the given one.- Specified by:
isEqualToin classGenericAssert<Float>- Parameters:
expected- the given value to compare the actual to.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not equal to the given one.- Since:
- 1.3
-
isEqualTo
Deprecated.use methodinstead. This method will be removed in version 2.0.isEqualTo(float, org.fest.assertions.Delta)Verifies that the actualFloatis equal to the given one, within a positive delta.- Parameters:
expected- the value to compare the actual one to.delta- the given delta.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not equal to the given one.
-
isEqualTo
Verifies that the actualFloatis equal to the given one, within a positive delta.- Parameters:
expected- the value to compare the actual one to.delta- the given delta.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not equal to the given one.- Since:
- 1.2
-
isEqualTo
-
isEqualTo
Verifies that the actualFloatis equal to the given one, within a positive delta.- Parameters:
expected- the value to compare the actual one to.delta- the given delta.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not equal to the given one.- Since:
- 1.3
-
isEqualTo
-
isNotEqualTo
Verifies that the actualFloatis not equal to the given one.- Parameters:
other- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis equal to the given one.
-
isGreaterThan
Verifies that the actualFloatis greater than the given one.- Parameters:
other- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not greater than the given one.
-
isLessThan
Verifies that the actualFloatis less than the given one.- Parameters:
other- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not less than the given one.
-
isGreaterThanOrEqualTo
Verifies that the actualFloatis greater or equal to the given one.- Parameters:
other- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not greater than or equal to the given one.
-
isLessThanOrEqualTo
Verifies that the actualFloatis less or equal to the given one.- Parameters:
other- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not less than or equal to the given one.
-
compareTo
private int compareTo(float other) -
isNaN
Verifies that the actualFloatis equal to.Float.NaN- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not equal toNaN.
-
isZero
Verifies that the actualFloatis equal to zero.- Specified by:
isZeroin interfaceNumberAssert- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not equal to zero.
-
isPositive
Verifies that the actualFloatis positive.- Specified by:
isPositivein interfaceNumberAssert- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not positive.
-
isNegative
Verifies that the actualFloatis negative.- Specified by:
isNegativein interfaceNumberAssert- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not negative.
-
delta
Deprecated.use methodinstead. This method will be removed in version 2.0.Delta.delta(double)Creates a new holder for a delta value to be used in.isEqualTo(float, org.fest.assertions.FloatAssert.Delta)- Parameters:
d- the delta value.- Returns:
- a new delta value holder.
-
overridingErrorMessage
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:
overridingErrorMessagein classGenericAssert<Float>- Parameters:
message- the given error message, which will replace the default one.- Returns:
- this assertion.
-
satisfies
Verifies that the actualsatisfies the given condition.Float- Specified by:
satisfiesin classGenericAssert<Float>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actualFloatdoes not satisfy the given condition.- Since:
- 1.3
- See Also:
-
doesNotSatisfy
Verifies that the actualdoes not satisfy the given condition.Float- Specified by:
doesNotSatisfyin classGenericAssert<Float>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actual value does satisfies the given condition.- Since:
- 1.3
- See Also:
-
is
Alias for.satisfies(Condition)- Specified by:
isin classGenericAssert<Float>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actualFloatdoes not satisfy the given condition.- Since:
- 1.3
-
isNot
Alias for.doesNotSatisfy(Condition)- Specified by:
isNotin classGenericAssert<Float>- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the actualFloatdoes not satisfy the given condition.- Since:
- 1.3
-
isNotEqualTo
Verifies that the actualis not equal to the given one.Float- Specified by:
isNotEqualToin classGenericAssert<Float>- Parameters:
other- the givenFloatto compare the actualFloatto.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis equal to the given one.- Since:
- 1.3
-
isNotNull
Verifies that the actualis notFloatnull.- Specified by:
isNotNullin classGenericAssert<Float>- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatisnull.- Since:
- 1.3
-
isSameAs
Verifies that the actualis the same object as the given one.Float- Specified by:
isSameAsin classGenericAssert<Float>- Parameters:
expected- the givenFloatto compare the actualFloatto.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis not the same as the given one.- Since:
- 1.3
-
isNotSameAs
Verifies that the actualis not the same object as the given one.Float- Specified by:
isNotSameAsin classGenericAssert<Float>- Parameters:
other- the givenFloatto compare the actualBigDecimalto.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualFloatis the same as the given one.- Since:
- 1.3
-
instead.Delta