Class OptionalDoubleSubject


  • public final class OptionalDoubleSubject
    extends Subject
    Propositions for Java 8 OptionalDouble subjects.
    Since:
    1.3.0 (previously part of truth-java8-extension)
    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.
      • optionalDoubles

        @Deprecated
        public static Subject.Factory<OptionalDoubleSubject,​java.util.OptionalDouble> optionalDoubles()
        Deprecated.
        Instead of about(optionalDoubles()).that(...), use just that(...). Similarly, instead of assertAbout(optionalDoubles()).that(...), use just assertThat(...).
        Obsolete factory instance. This factory was previously necessary for assertions like assertWithMessage(...).about(optionalDoubles()).that(optional)..... Now, you can perform assertions like that without the about(...) call.