Class OptionalDoubleSubject
java.lang.Object
com.google.common.truth.Subject
com.google.common.truth.OptionalDoubleSubject
A subject for
OptionalDouble
values.- Since:
- 1.3.0 (previously part of
truth-java8-extension
) - Author:
- Ben Douglass
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.Factory<SubjectT extends Subject, ActualT>
-
Method Summary
Modifier and TypeMethodDescriptionvoid
hasValue
(double expected) Checks that the actualOptionalDouble
contains the given value.void
isEmpty()
Checks that the actualOptionalDouble
does not contain a value.void
Checks that the actualOptionalDouble
contains a value.Deprecated.Methods inherited from class com.google.common.truth.Subject
actualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString
-
Method Details
-
isPresent
public void isPresent()Checks that the actualOptionalDouble
contains a value. -
isEmpty
public void isEmpty()Checks that the actualOptionalDouble
does not contain a value. -
hasValue
public void hasValue(double expected) Checks that the actualOptionalDouble
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 usingassertThat(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.Instead ofabout(optionalDoubles()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(optionalDoubles()).that(...)
, use justassertThat(...)
.Obsolete factory instance. This factory was previously necessary for assertions likeassertWithMessage(...).about(optionalDoubles()).that(optional)....
. Now, you can perform assertions like that without theabout(...)
call.
-
about(optionalDoubles()).that(...)
, use justthat(...)
.