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)
-
Nested Class Summary
Nested classes/interfaces inherited from class Subject
Subject.Factory<SubjectT,ActualT> -
Method Summary
Modifier and TypeMethodDescriptionvoidhasValue(double expected) Checks that the actualOptionalDoublecontains the given value.voidisEmpty()Checks that the actualOptionalDoubledoes not contain a value.voidChecks that the actualOptionalDoublecontains a value.Deprecated.Methods inherited from class Subject
actualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toStringModifier and TypeMethodDescriptionprotected StringReturns a string representation of the actual value for inclusion in failure messages.protected final StandardSubjectBuilderReturns a builder for creating a derived subject.final booleanDeprecated.Object.equals(Object)is not supported on Truth subjects.protected final voidfailWithActual(Fact first, Fact... rest) Fails, reporting a message with the given facts, followed by an automatically added fact of the form: but was: actual value.protected final voidfailWithActual(String key, @Nullable Object value) Fails, reporting a message with two "facts": key: value but was: actual value.protected final voidfailWithoutActual(Fact first, Fact... rest) Fails, reporting a message with the given facts, without automatically adding the actual value.final inthashCode()Deprecated.Object.hashCode()is not supported on Truth subjects.protected final StandardSubjectBuilderBegins a new call chain that ignores any failures.voidChecks that the value under test is equal to any of the given elements.voidChecks that the value under test is equal to the given object.voidChecks that the value under test is equal to any element in the given iterable.voidisInstanceOf(@Nullable Class<?> clazz) Checks that the value under test is an instance of the given class.voidChecks that the value under test is not equal to any of the given elements.voidisNotEqualTo(@Nullable Object other) Checks that the value under test is not equal to the given object.voidChecks that the value under test is not equal to any element in the given iterable.voidisNotInstanceOf(@Nullable Class<?> clazz) Checks that the value under test is not an instance of the given class.voidChecks that the value under test is not null.final voidisNotSameInstanceAs(@Nullable Object other) Checks that the value under test is not the same instance as the given object.voidisNull()Checks that the value under test is null.final voidisSameInstanceAs(@Nullable Object expected) Checks that the value under test is the same instance as the given object.toString()Deprecated.Object.toString()is not supported on Truth subjects.
-
Method Details
-
isPresent
public void isPresent()Checks that the actualOptionalDoublecontains a value. -
isEmpty
public void isEmpty()Checks that the actualOptionalDoubledoes not contain a value. -
hasValue
public void hasValue(double expected) Checks that the actualOptionalDoublecontains 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(...).