Package org.fest.assertions
Class DoubleAssert
- All Implemented Interfaces:
NumberAssert
Understands Assertion methods for
Double
s and double
s. To create a new instance of this class call
Assertions.assertThat(Double)
or Assertions.assertThat(double)
.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.fest.assertions.GenericAssert
actual
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DoubleAssert
(double actual) Creates a new
.DoubleAssert
protected
DoubleAssert
(Double actual) Creates a new
.DoubleAssert
-
Method Summary
Modifier and TypeMethodDescriptionSets the description of the actual value, to be used in as message of any
thrown when an assertion fails.AssertionError
as
(Description description) Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails.AssertionError
private int
compareTo
(double other) static DoubleAssert.Delta
delta
(double d) Deprecated.use method
instead.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<Double> condition) Verifies that the actualDouble
does not satisfy the given condition.Alias for
.satisfies(Condition)
isEqualTo
(double expected) Verifies that the actualDouble
is equal to the given one.private DoubleAssert
isEqualTo
(double expected, double deltaValue) Verifies that the actualDouble
is equal to the given one, within a positive delta.isEqualTo
(double expected, DoubleAssert.Delta delta) Deprecated.use method
instead.isEqualTo(double, org.fest.assertions.Delta)
Verifies that the actualDouble
is equal to the given one.private DoubleAssert
Verifies that the actualDouble
is equal to the given one, within a positive delta.isGreaterThan
(double other) Verifies that the actualDouble
is greater than the given one.isGreaterThanOrEqualTo
(double other) Verifies that the actualDouble
is greater or equal to the given one.isLessThan
(double other) Verifies that the actualDouble
is less than the given one.isLessThanOrEqualTo
(double other) Verifies that the actualDouble
is less or equal to the given one.isNaN()
Verifies that the actualDouble
is equal to
.Double.NaN
Verifies that the actualDouble
is negative.Alias for
.doesNotSatisfy(Condition)
isNotEqualTo
(double other) Verifies that the actualDouble
is not equal to the given one.isNotEqualTo
(Double other) Verifies that the actualDouble
is not equal to the given one.Verifies that the actualDouble
is notnull
.isNotSameAs
(Double other) Verifies that the actualDouble
is not the same object as the given one.Verifies that the actualDouble
is positive.Verifies that the actualDouble
is the same object as the given one.isZero()
Verifies that the actualDouble
is equal to zero.overridingErrorMessage
(String message) Replaces the default message displayed in case of a failure with the given one.Verifies that the actualDouble
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
-
Field Details
-
ZERO
private static final double ZERO- See Also:
-
-
Constructor Details
-
DoubleAssert
protected DoubleAssert(double actual) Creates a new
.DoubleAssert
- Parameters:
actual
- the actual value to verify.
-
DoubleAssert
Creates a new
.DoubleAssert
- Parameters:
actual
- the actual value to verify.
-
-
Method Details
-
as
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionError
For example:
assertThat(val).as("name").isEqualTo("Frodo");
- Specified by:
as
in classGenericAssert<Double>
- 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:
describedAs
in classGenericAssert<Double>
- 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 any
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionError
For example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
- Specified by:
as
in classGenericAssert<Double>
- 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:
describedAs
in classGenericAssert<Double>
- Parameters:
description
- the description of the actual value.- Returns:
- this assertion object.
-
isEqualTo
Verifies that the actualDouble
is equal to the given one.- Parameters:
expected
- the value to compare the actual one to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not equal to the given one.
-
isEqualTo
Verifies that the actualDouble
is equal to the given one.- Specified by:
isEqualTo
in classGenericAssert<Double>
- Parameters:
expected
- the given value to compare the actualDouble
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not equal to the given one.- Since:
- 1.3
-
isEqualTo
Deprecated.use method
instead. This method will be removed in version 2.0.isEqualTo(double, org.fest.assertions.Delta)
Verifies that the actualDouble
is 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 actualDouble
is not equal to the given one.
-
isEqualTo
Verifies that the actualDouble
is 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 actualDouble
is not equal to the given one.- Since:
- 1.1
-
isEqualTo
-
isEqualTo
Verifies that the actualDouble
is 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 actualDouble
is not equal to the given one.- Since:
- 1.3
-
isEqualTo
-
isNotEqualTo
Verifies that the actualDouble
is not equal to the given one.- Parameters:
other
- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is equal to the given one.
-
isGreaterThan
Verifies that the actualDouble
is greater than the given one.- Parameters:
other
- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not greater than the given one.
-
isLessThan
Verifies that the actualDouble
is less than the given one.- Parameters:
other
- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not less than the given one.
-
isGreaterThanOrEqualTo
Verifies that the actualDouble
is greater or equal to the given one.- Parameters:
other
- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not greater than or equal to the given one.
-
isLessThanOrEqualTo
Verifies that the actualDouble
is less or equal to the given one.- Parameters:
other
- the given value.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not less than or equal to the given one.
-
compareTo
private int compareTo(double other) -
isZero
Verifies that the actualDouble
is equal to zero.- Specified by:
isZero
in interfaceNumberAssert
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not equal to zero.
-
isPositive
Verifies that the actualDouble
is positive.- Specified by:
isPositive
in interfaceNumberAssert
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not positive.
-
isNegative
Verifies that the actualDouble
is negative.- Specified by:
isNegative
in interfaceNumberAssert
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not negative.
-
isNaN
Verifies that the actualDouble
is equal to
.Double.NaN
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not equal toNAN
.
-
delta
Deprecated.use method
instead. 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(double, org.fest.assertions.DoubleAssert.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:
overridingErrorMessage
in classGenericAssert<Double>
- Parameters:
message
- the given error message, which will replace the default one.- Returns:
- this assertion.
-
satisfies
Verifies that the actualDouble
satisfies the given condition.- Specified by:
satisfies
in classGenericAssert<Double>
- Parameters:
condition
- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if the actualDouble
does not satisfy the given condition.- Since:
- 1.3
- See Also:
-
doesNotSatisfy
Verifies that the actualDouble
does not satisfy the given condition.- Specified by:
doesNotSatisfy
in classGenericAssert<Double>
- 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:
is
in classGenericAssert<Double>
- Parameters:
condition
- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if the actualDouble
does not satisfy the given condition.- Since:
- 1.3
-
isNot
Alias for
.doesNotSatisfy(Condition)
- Specified by:
isNot
in classGenericAssert<Double>
- Parameters:
condition
- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if the actualDouble
does not satisfy the given condition.- Since:
- 1.3
-
isNotEqualTo
Verifies that the actualDouble
is not equal to the given one.- Specified by:
isNotEqualTo
in classGenericAssert<Double>
- Parameters:
other
- the givenDouble
to compare the actualDouble
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is equal to the given one.- Since:
- 1.3
-
isNotNull
Verifies that the actualDouble
is notnull
.- Specified by:
isNotNull
in classGenericAssert<Double>
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
isnull
.- Since:
- 1.3
-
isSameAs
Verifies that the actualDouble
is the same object as the given one.- Specified by:
isSameAs
in classGenericAssert<Double>
- Parameters:
expected
- the givenDouble
to compare the actualDouble
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is not the same as the given one.- Since:
- 1.3
-
isNotSameAs
Verifies that the actualDouble
is not the same object as the given one.- Specified by:
isNotSameAs
in classGenericAssert<Double>
- Parameters:
other
- the givenDouble
to compare the actualBigDecimal
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualDouble
is the same as the given one.- Since:
- 1.3
-
instead.Delta