Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -833,4 +833,86 @@ public void hasLengthNullArray() {
private static float[] array(float... primitives) {
return primitives;
}

@Test
public void isEmpty_emptyArray_success() {
assertThat(array()).isEmpty();
}

@Test
public void isEmpty_nonEmptyArray_failure() {
expectFailure(whenTesting -> whenTesting.that(array(1.0f)).isEmpty());
}

@Test
public void isNotEmpty_nonEmptyArray_success() {
assertThat(array(1.0f)).isNotEmpty();
}

@Test
public void isNotEmpty_emptyArray_failure() {
expectFailure(whenTesting -> whenTesting.that(array()).isNotEmpty());
}

@Test
public void usingExactEquality_nullArray_failure() {
expectFailure(
whenTesting ->
whenTesting.that((float[]) null).usingExactEquality().contains(1.0f));
}

@Test
public void usingTolerance_nullArray_failure() {
expectFailure(
whenTesting ->
whenTesting.that((float[]) null).usingTolerance(0.001).contains(1.0f));
}

@Test
public void usingExactEquality_contains_otherTypes_negativeIntOutOfRange() {
int expected = -(1 << 24) - 1;
float[] actual = array(1.0f, 2.0f, 3.0f);
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(actual).usingExactEquality().contains(expected));
assertThat(e)
.factValue("first exception")
.startsWith(
"compare("
+ actual[0]
+ ", "
+ expected
+ ") threw java.lang.IllegalArgumentException");
assertThat(e)
.factValue("first exception")
.contains(
"Expected value "
+ expected
+ " in assertion using exact float equality was an int with an absolute value "
+ "greater than 2^24 which has no exact float representation");
}

@Test
public void usingExactEquality_contains_otherTypes_negativeLongOutOfRange() {
long expected = -(1L << 24) - 1L;
float[] actual = array(1.0f, 2.0f, 3.0f);
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(actual).usingExactEquality().contains(expected));
assertThat(e)
.factValue("first exception")
.startsWith(
"compare("
+ actual[0]
+ ", "
+ expected
+ ") threw java.lang.IllegalArgumentException");
assertThat(e)
.factValue("first exception")
.contains(
"Expected value "
+ expected
+ " in assertion using exact float equality was a long with an absolute value "
+ "greater than 2^24 which has no exact float representation");
}
}