Package com.google.common.truth
Class OptionalDoubleSubject
java.lang.Object
com.google.common.truth.Subject
com.google.common.truth.OptionalDoubleSubject
Propositions for Java 8
OptionalDouble
subjects.-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.EqualityCheck, Subject.Factory<SubjectT extends Subject,
ActualT> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOptionalDoubleSubject
(FailureMetadata failureMetadata, OptionalDouble subject, String typeDescription) -
Method Summary
Modifier and TypeMethodDescriptionvoid
hasValue
(double expected) Fails if theOptionalDouble
does not have the given value or the subject is null.void
isEmpty()
Fails if theOptionalDouble
is present or the subject is null.void
Fails if theOptionalDouble
is empty or the subject is null.Methods inherited from class com.google.common.truth.Subject
actual, actualCustomStringRepresentation, actualCustomStringRepresentationForPackageMembersToCall, butWas, check, check, checkNoNeedToDisplayBothValues, equals, fail, fail, fail, failEqualityCheckForEqualsWithoutDescription, failWithActual, failWithActual, failWithActual, failWithActual, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutActual, failWithoutActual, failWithoutActual, failWithoutSubject, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString, typeDescription
-
Field Details
-
actual
-
-
Constructor Details
-
OptionalDoubleSubject
OptionalDoubleSubject(FailureMetadata failureMetadata, OptionalDouble subject, String typeDescription)
-
-
Method Details
-
isPresent
public void isPresent()Fails if theOptionalDouble
is empty or the subject is null. -
isEmpty
public void isEmpty()Fails if theOptionalDouble
is present or the subject is null. -
hasValue
public void hasValue(double expected) Fails if theOptionalDouble
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 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
-