add more complex numerical equality test
@@ -9,7 +9,7 @@ import static org.junit.Assert.assertArrayEquals;
public class NumericalEqualsVertexTest {
@Test
- public void canNumbersNotEqual() {
+ public void canCompareNumbersNotEqual() {
NumericalEqualsVertex equals = new NumericalEqualsVertex(
ConstantVertex.of(new double[]{1, 2, 3}),
@@ -21,4 +21,32 @@ public class NumericalEqualsVertexTest {
assertArrayEquals(new Boolean[]{false, false, false}, equality.asFlatArray());
}
+
+ @Test
+ public void canCompareNumbersEqual() {
+
+ NumericalEqualsVertex equals = new NumericalEqualsVertex(
+ ConstantVertex.of(new double[]{1, 2, 3}),
+ ConstantVertex.of(new double[]{1, 2, 3}),
+ ConstantVertex.of(new double[]{0, 0, 0})
+ );
+
+ BooleanTensor equality = equals.lazyEval();
+
+ assertArrayEquals(new Boolean[]{true, true, true}, equality.asFlatArray());
+ }
+
+ @Test
+ public void canCompareNumbersAlmostEqual() {
+
+ NumericalEqualsVertex equals = new NumericalEqualsVertex(
+ ConstantVertex.of(new double[]{1, 2, 3}),
+ ConstantVertex.of(new double[]{1.5, 2.01, 3}),
+ ConstantVertex.of(new double[]{0.1, 0.1, 0.1})
+ );
+
+ BooleanTensor equality = equals.lazyEval();
+
+ assertArrayEquals(new Boolean[]{false, true, true}, equality.asFlatArray());
+ }
}
