S
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation"
for more details.public abstract class AbstractByteAssert<S extends AbstractByteAssert<S>> extends AbstractComparableAssert<S,Byte> implements NumberAssert<S,Byte>
Byte
s.actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
AbstractByteAssert(Byte actual,
Class<?> selfType) |
Modifier and Type | Method and Description |
---|---|
S |
isBetween(Byte start,
Byte end)
Verifies that the actual value is in [start, end] range (start included, end included).
|
S |
isCloseTo(byte expected,
Offset<Byte> offset)
Verifies that the actual byte is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid. |
S |
isCloseTo(Byte expected,
Offset<Byte> offset)
Verifies that the actual Byte is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid. |
S |
isCloseTo(byte expected,
Percentage percentage)
Verifies that the actual number is close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid. |
S |
isCloseTo(Byte expected,
Percentage percentage)
Verifies that the actual number is close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid. |
S |
isEqualTo(byte expected)
Verifies that the actual value is equal to the given one.
|
S |
isGreaterThan(byte other)
Verifies that the actual value is greater than the given one.
|
S |
isGreaterThanOrEqualTo(byte other)
Verifies that the actual value is greater than or equal to the given one.
|
S |
isLessThan(byte other)
Verifies that the actual value is less than the given one.
|
S |
isLessThanOrEqualTo(byte other)
Verifies that the actual value is less than or equal to the given one.
|
S |
isNegative()
Verifies that the actual value is negative.
|
S |
isNotEqualTo(byte other)
Verifies that the actual value is not equal to the given one.
|
S |
isNotNegative()
Verifies that the actual value is non negative (positive or equal zero).
|
S |
isNotPositive()
Verifies that the actual value is non positive (negative or equal zero).
|
S |
isNotZero()
Verifies that the actual value is not equal to zero.
|
S |
isPositive()
Verifies that the actual value is positive.
|
S |
isStrictlyBetween(Byte start,
Byte end)
Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).
|
S |
isZero()
Verifies that the actual value is equal to zero.
|
S |
usingComparator(Comparator<? super Byte> customComparator)
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks.
|
S |
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks.
|
inBinary, inHexadecimal, isEqualByComparingTo, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, isNotEqualByComparingTo
isEqualToComparingFieldByField, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failure, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasToString, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, overridingErrorMessage, withThreadDumpOnError
public S isEqualTo(byte expected)
expected
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is not equal to the given one.public S isNotEqualTo(byte other)
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is equal to the given one.public S isZero()
isZero
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
public S isNotZero()
isNotZero
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
public S isPositive()
Example:
// assertion will pass
assertThat((byte) 1).isPositive();
// assertion will fail
assertThat((byte) -1).isPositive();
isPositive
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
public S isNegative()
Example:
// assertion will pass
assertThat((byte) -1).isNegative();
// assertion will fail
assertThat((byte) 1).isNegative();
isNegative
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
public S isNotNegative()
Example:
// assertion will pass
assertThat((byte) 1).isNotNegative();
// assertion will fail
assertThat((byte) -1).isNotNegative();
isNotNegative
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
this
assertion object.public S isNotPositive()
Example:
// assertion will pass
assertThat((byte) -1).isNotPositive();
// assertion will fail
assertThat((byte) 1).isNotPositive();
isNotPositive
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
this
assertion object.public S isLessThan(byte other)
Example:
// assertion will pass
assertThat((byte) 1).isLessThan(2);
// assertion will fail
assertThat((byte) 1).isLessThan(0);
assertThat((byte) 1).isLessThan(1);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is equal to or greater than the given one.public S isLessThanOrEqualTo(byte other)
Example:
// assertion will pass
assertThat((byte) 1).isLessThanOrEqualTo(2);
assertThat((byte) 1).isLessThanOrEqualTo(1);
// assertion will fail
assertThat((byte) 1).isLessThanOrEqualTo(0);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is greater than the given one.public S isGreaterThan(byte other)
Example:
// assertion will pass
assertThat((byte) 2).isGreaterThan(1);
// assertion will fail
assertThat((byte) 2).isGreaterThan(3);
assertThat((byte) 2).isGreaterThan(2);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is equal to or less than the given one.public S isGreaterThanOrEqualTo(byte other)
Example:
// assertion will pass
assertThat((byte) 2).isGreaterThanOrEqualTo(1);
assertThat((byte) 2).isGreaterThanOrEqualTo(2);
// assertion will fail
assertThat((byte) 2).isGreaterThanOrEqualTo(3);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is less than the given one.public S isBetween(Byte start, Byte end)
Example:
// assertions will pass
assertThat((byte) 1).isBetween((byte) -1, (byte) 2);
assertThat((byte) 1).isBetween((byte) 1, (byte) 2);
assertThat((byte) 1).isBetween((byte) 0, (byte) 1);
// assertion will fail
assertThat((byte) 1).isBetween((byte) 2, (byte) 3);
isBetween
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
start
- the start value (inclusive), expected not to be null.end
- the end value (inclusive), expected not to be null.public S isStrictlyBetween(Byte start, Byte end)
Example:
// assertion will pass
assertThat((byte) 1).isStrictlyBetween((byte) -1, (byte) 2);
// assertions will fail
assertThat((byte) 1).isStrictlyBetween((byte) 1, (byte) 2);
assertThat((byte) 1).isStrictlyBetween((byte) 0, (byte) 1);
assertThat((byte) 1).isStrictlyBetween((byte) 2, (byte) 3);
isStrictlyBetween
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
start
- the start value (exclusive), expected not to be null.end
- the end value (exclusive), expected not to be null.public S isCloseTo(byte expected, Offset<Byte> offset)
Example :
// assertions will pass:
assertThat((byte)5).isCloseTo((byte)7, within((byte)3));
// if difference is exactly equals to the offset, it's ok
assertThat((byte)5).isCloseTo((byte)7, within((byte)2));
// assertion will fail
assertThat((byte)5).isCloseTo((byte)7, within((byte)1));
expected
- the given byte to compare the actual value to.offset
- the given positive offset.this
assertion object.NullPointerException
- if the given offset is null
.AssertionError
- if the actual value is not equal to the given one.public S isCloseTo(Byte expected, Offset<Byte> offset)
Example :
// assertions will pass:
assertThat((byte)5).isCloseTo(new Byte("7"), within((byte)3));
// if difference is exactly equals to the offset, it's ok
assertThat((byte)5).isCloseTo(new Byte("7"), within((byte)2));
// assertion will fail
assertThat((byte)5).isCloseTo(new Byte("7"), within((byte)1));
isCloseTo
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
expected
- the given Byte to compare the actual value to.offset
- the given positive offset.this
assertion object.NullPointerException
- if the given offset is null
.NullPointerException
- if the expected Byte is null
.AssertionError
- if the actual value is not equal to the given one.public S isCloseTo(Byte expected, Percentage percentage)
Example with byte:
// assertions will pass:
assertThat((byte)11).isCloseTo(Byte.valueOf(10), withinPercentage((byte)20));
// if difference is exactly equals to the computed offset (1), it's ok
assertThat((byte)11).isCloseTo(Byte.valueOf(10), withinPercentage((byte)10));
// assertion will fail
assertThat((byte)11).isCloseTo(Byte.valueOf(10), withinPercentage((byte)5));
isCloseTo
in interface NumberAssert<S extends AbstractByteAssert<S>,Byte>
expected
- the given number to compare the actual value to.percentage
- the given positive percentage between 0 and 100.this
assertion object.NullPointerException
- if the given offset is null
.NullPointerException
- if the expected number is null
.AssertionError
- if the actual value is not equal to the given one.public S isCloseTo(byte expected, Percentage percentage)
Example with byte:
// assertions will pass:
assertThat((byte)11).isCloseTo((byte)10, withinPercentage((byte)20));
// if difference is exactly equals to the computed offset (1), it's ok
assertThat((byte)11).isCloseTo((byte)10, withinPercentage((byte)10));
// assertion will fail
assertThat((byte)11).isCloseTo((byte)10, withinPercentage((byte)5));
expected
- the given number to compare the actual value to.percentage
- the given positive percentage between 0 and 100.this
assertion object.NullPointerException
- if the given offset is null
.NullPointerException
- if the expected number is null
.AssertionError
- if the actual value is not equal to the given one.public S usingComparator(Comparator<? super Byte> customComparator)
AbstractAssert
Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.
Examples :
// frodo and sam are instances of Character with Hobbit race (obviously :).
// raceComparator implements Comparator<Character>
assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam);
usingComparator
in interface Assert<S extends AbstractByteAssert<S>,Byte>
usingComparator
in class AbstractComparableAssert<S extends AbstractByteAssert<S>,Byte>
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.public S usingDefaultComparator()
AbstractAssert
This method should be used to disable a custom comparison strategy set by calling
Assert.usingComparator(Comparator)
.
usingDefaultComparator
in interface Assert<S extends AbstractByteAssert<S>,Byte>
usingDefaultComparator
in class AbstractComparableAssert<S extends AbstractByteAssert<S>,Byte>
this
assertion object.Copyright © 2014-2015 AssertJ. All Rights Reserved.