Class LongSubject


public class LongSubject extends ComparableSubject<Long>
A subject for long values.
Author:
David Saff, Christian Gruber (cgruber@israfil.net), Kurt Alfred Kluever
  • Constructor Details

    • LongSubject

      protected LongSubject(FailureMetadata metadata, @Nullable Long actual)
      Constructor for use by subclasses. If you want to create an instance of this class itself, call check(...).that(actual).
  • Method Details

    • isWithin

      public LongSubject.TolerantLongComparison isWithin(long tolerance)
      Prepares for a check that the actual value is a number within the given tolerance of an expected value that will be provided in the next call in the fluent chain.
      Parameters:
      tolerance - an inclusive upper bound on the difference between the actual value and expected value allowed by the check, which must be a non-negative value.
      Since:
      1.2
    • isNotWithin

      public LongSubject.TolerantLongComparison isNotWithin(long tolerance)
      Prepares for a check that the actual value is a number not within the given tolerance of an expected value that will be provided in the next call in the fluent chain.
      Parameters:
      tolerance - an exclusive lower bound on the difference between the actual value and expected value allowed by the check, which must be a non-negative value.
      Since:
      1.2
    • isEquivalentAccordingToCompareTo

      @Deprecated public final void isEquivalentAccordingToCompareTo(@Nullable Long other)
      Deprecated.
      Use Subject.isEqualTo(java.lang.Object) instead. Long comparison is consistent with equality.
      Description copied from class: ComparableSubject
      Checks that the actual value is equivalent to other according to Comparable.compareTo(T), (i.e., checks that a.comparesTo(b) == 0).

      Note: Do not use this method for checking object equality. Instead, use Subject.isEqualTo(Object).

      Overrides:
      isEquivalentAccordingToCompareTo in class ComparableSubject<Long>
    • isGreaterThan

      public final void isGreaterThan(int other)
      Checks that the actual value is greater than other.

      To check that the actual value is greater than or equal to other, use isAtLeast(int).

    • isLessThan

      public final void isLessThan(int other)
      Checks that the actual value is less than other.

      To check that the actual value is less than or equal to other, use isAtMost(int) .

    • isAtMost

      public final void isAtMost(int other)
      Checks that the actual value is less than or equal to other.

      To check that the actual value is strictly less than other, use isLessThan(int).

    • isAtLeast

      public final void isAtLeast(int other)
      Checks that the actual value is greater than or equal to other.

      To check that the actual value is strictly greater than other, use isGreaterThan(int).