Class OptionalDoubleSubject


  • public final class OptionalDoubleSubject
    extends Subject
    Propositions for Java 8 OptionalDouble subjects.
    Author:
    Ben Douglass
    • Method Detail

      • isPresent

        public void isPresent()
        Fails if the OptionalDouble is empty or the subject is null.
      • isEmpty

        public void isEmpty()
        Fails if the OptionalDouble is present or the subject is null.
      • hasValue

        public void hasValue​(double expected)
        Fails if the OptionalDouble does not have the given value or the subject is null. This method is not recommended when the code under test is doing any kind of arithmetic, since the exact result of floating point arithmetic is sensitive to apparently trivial changes. More sophisticated comparisons can be done using assertThat(optional.getAsDouble())…. This method is recommended when the code under test is specified as either copying a value without modification from its input or returning a well-defined literal or constant value.