Class FloatAssert

All Implemented Interfaces:
NumberAssert

public class FloatAssert extends GenericAssert<Float> implements NumberAssert
Understands assertion methods for Floats and floats. To create a new instance of this class call Assertions.assertThat(Float) or Assertions.assertThat(float).
  • Field Details

  • Constructor Details

    • FloatAssert

      protected FloatAssert(float actual)
      Creates a new FloatAssert.
      Parameters:
      actual - the actual value to verify.
    • FloatAssert

      protected FloatAssert(Float actual)
      Creates a new FloatAssert.
      Parameters:
      actual - the actual value to verify.
  • Method Details

    • as

      public FloatAssert 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<Float>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public FloatAssert 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<Float>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • as

      public FloatAssert 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<Float>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • describedAs

      public FloatAssert 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<Float>
      Parameters:
      description - the description of the actual value.
      Returns:
      this assertion object.
    • isEqualTo

      public FloatAssert isEqualTo(float expected)
      Verifies that the actual Float is equal to the given one.
      Parameters:
      expected - the value to compare the actual one to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not equal to the given one.
    • isEqualTo

      public FloatAssert isEqualTo(Float expected)
      Verifies that the actual Float is equal to the given one.
      Specified by:
      isEqualTo in class GenericAssert<Float>
      Parameters:
      expected - the given value to compare the actual to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not equal to the given one.
      Since:
      1.3
    • isEqualTo

      @Deprecated public FloatAssert isEqualTo(float expected, FloatAssert.Delta delta)
      Deprecated.
      use method isEqualTo(float, org.fest.assertions.Delta) instead. This method will be removed in version 2.0.
      Verifies that the actual Float 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 actual Float is not equal to the given one.
    • isEqualTo

      public FloatAssert isEqualTo(float expected, Delta delta)
      Verifies that the actual Float 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 actual Float is not equal to the given one.
      Since:
      1.2
    • isEqualTo

      private FloatAssert isEqualTo(float expected, float deltaValue)
    • isEqualTo

      public FloatAssert isEqualTo(Float expected, Delta delta)
      Verifies that the actual Float 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 actual Float is not equal to the given one.
      Since:
      1.3
    • isEqualTo

      private FloatAssert isEqualTo(Float expected, float deltaValue)
    • isNotEqualTo

      public FloatAssert isNotEqualTo(float other)
      Verifies that the actual Float is not equal to the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is equal to the given one.
    • isGreaterThan

      public FloatAssert isGreaterThan(float other)
      Verifies that the actual Float is greater than the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not greater than the given one.
    • isLessThan

      public FloatAssert isLessThan(float other)
      Verifies that the actual Float is less than the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not less than the given one.
    • isGreaterThanOrEqualTo

      public FloatAssert isGreaterThanOrEqualTo(float other)
      Verifies that the actual Float is greater or equal to the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not greater than or equal to the given one.
    • isLessThanOrEqualTo

      public FloatAssert isLessThanOrEqualTo(float other)
      Verifies that the actual Float is less or equal to the given one.
      Parameters:
      other - the given value.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not less than or equal to the given one.
    • compareTo

      private int compareTo(float other)
    • isNaN

      public FloatAssert isNaN()
      Verifies that the actual Float is equal to Float.NaN.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not equal to NaN.
    • isZero

      public FloatAssert isZero()
      Verifies that the actual Float is equal to zero.
      Specified by:
      isZero in interface NumberAssert
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not equal to zero.
    • isPositive

      public FloatAssert isPositive()
      Verifies that the actual Float is positive.
      Specified by:
      isPositive in interface NumberAssert
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not positive.
    • isNegative

      public FloatAssert isNegative()
      Verifies that the actual Float is negative.
      Specified by:
      isNegative in interface NumberAssert
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not negative.
    • delta

      @Deprecated public static FloatAssert.Delta delta(float d)
      Deprecated.
      use method Delta.delta(double) instead. This method will be removed in version 2.0.
      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

      public FloatAssert 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<Float>
      Parameters:
      message - the given error message, which will replace the default one.
      Returns:
      this assertion.
    • satisfies

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

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

      public FloatAssert is(Condition<Float> condition)
      Specified by:
      is in class GenericAssert<Float>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual Float does not satisfy the given condition.
      Since:
      1.3
    • isNot

      public FloatAssert isNot(Condition<Float> condition)
      Specified by:
      isNot in class GenericAssert<Float>
      Parameters:
      condition - the given condition.
      Returns:
      this assertion object.
      Throws:
      NullPointerException - if the given condition is null.
      AssertionError - if the actual Float does not satisfy the given condition.
      Since:
      1.3
    • isNotEqualTo

      public FloatAssert isNotEqualTo(Float other)
      Verifies that the actual Float is not equal to the given one.
      Specified by:
      isNotEqualTo in class GenericAssert<Float>
      Parameters:
      other - the given Float to compare the actual Float to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is equal to the given one.
      Since:
      1.3
    • isNotNull

      public FloatAssert isNotNull()
      Verifies that the actual Float is not null.
      Specified by:
      isNotNull in class GenericAssert<Float>
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is null.
      Since:
      1.3
    • isSameAs

      public FloatAssert isSameAs(Float expected)
      Verifies that the actual Float is the same object as the given one.
      Specified by:
      isSameAs in class GenericAssert<Float>
      Parameters:
      expected - the given Float to compare the actual Float to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is not the same as the given one.
      Since:
      1.3
    • isNotSameAs

      public FloatAssert isNotSameAs(Float other)
      Verifies that the actual Float is not the same object as the given one.
      Specified by:
      isNotSameAs in class GenericAssert<Float>
      Parameters:
      other - the given Float to compare the actual BigDecimal to.
      Returns:
      this assertion object.
      Throws:
      AssertionError - if the actual Float is the same as the given one.
      Since:
      1.3