Class OptionalDoubleSubject


  • public final class OptionalDoubleSubject
    extends Subject
    A subject for OptionalDouble values.
    Since:
    1.3.0 (previously part of truth-java8-extension)
    • Method Detail

      • isPresent

        public void isPresent()
        Checks that the actual OptionalDouble contains a value.
      • isEmpty

        public void isEmpty()
        Checks that the actual OptionalDouble does not contain a value.
      • hasValue

        public void hasValue​(double expected)
        Checks that the actual OptionalDouble contains the given value. 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,​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.