Skip to content

Commit

Permalink
Merge pull request #61 from darkma773r/geometry-63
Browse files Browse the repository at this point in the history
GEOMETRY-63: Updated Assertion Method Names
  • Loading branch information
aherbert committed Jan 28, 2020
2 parents f8127fc + fb28076 commit 0df749c
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 89 deletions.
Expand Up @@ -42,17 +42,17 @@ public void testLinecast_line_simple() {

// no intersections
LinecastChecker3D.with(linecaster)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(0, 4, 4), Vector3D.Unit.MINUS_X, TEST_PRECISION));

// through center; two directions
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(0, 0.5, 0.5), Vector3D.Unit.MINUS_X)
.expect(Vector3D.of(0, 0.5, 0.5), Vector3D.Unit.MINUS_X)
.and(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(0.5, 0.5, 0.5), Vector3D.Unit.PLUS_X, TEST_PRECISION));

LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.expect(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.and(Vector3D.of(0, 0.5, 0.5), Vector3D.Unit.MINUS_X)
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(0.5, 0.5, 0.5), Vector3D.Unit.MINUS_X, TEST_PRECISION));
}
Expand All @@ -64,7 +64,7 @@ public void testLinecast_line_alongFace() {

// act/assert
LinecastChecker3D.with(linecaster)
.returns(Vector3D.ZERO, Vector3D.Unit.MINUS_Y)
.expect(Vector3D.ZERO, Vector3D.Unit.MINUS_Y)
.and(Vector3D.ZERO, Vector3D.Unit.MINUS_Z)
.and(Vector3D.of(0, 1, 1), Vector3D.Unit.PLUS_Z)
.and(Vector3D.of(0, 1, 1), Vector3D.Unit.PLUS_Y)
Expand All @@ -80,14 +80,14 @@ public void testLinecast_line_corners() {

// through single corner vertex
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Z)
.expect(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Z)
.and(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Y)
.and(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_X)
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(1, 1, 1), Vector3D.of(1, -1, -1), TEST_PRECISION));

// through two corner vertices
LinecastChecker3D.with(linecaster)
.returns(Vector3D.ZERO, Vector3D.Unit.MINUS_X)
.expect(Vector3D.ZERO, Vector3D.Unit.MINUS_X)
.and(Vector3D.ZERO, Vector3D.Unit.MINUS_Y)
.and(Vector3D.ZERO, Vector3D.Unit.MINUS_Z)
.and(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Z)
Expand All @@ -107,7 +107,7 @@ public void testLinecast_line_removesDuplicatePoints() {

// act/assert
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(0, 0.5, 0), Vector3D.Unit.PLUS_Z)
.expect(Vector3D.of(0, 0.5, 0), Vector3D.Unit.PLUS_Z)
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(-1, 0.5, 1), Vector3D.of(1, 0, -1), TEST_PRECISION));
}

Expand All @@ -120,25 +120,25 @@ public void testLinecast_segment_simple() {

// no intersections; underlying line does not intersect
LinecastChecker3D.with(linecaster)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(0, 4, 4), Vector3D.Unit.MINUS_X, TEST_PRECISION)
.segment(-10, 10));

// no intersections; underlying line does intersect
LinecastChecker3D.with(linecaster)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(0.5, 0.5, 0.5), Vector3D.Unit.PLUS_X, TEST_PRECISION)
.segment(2, 10));

// no boundaries excluded; two directions
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(0, 0.5, 0.5), Vector3D.Unit.MINUS_X)
.expect(Vector3D.of(0, 0.5, 0.5), Vector3D.Unit.MINUS_X)
.and(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(0.5, 0.5, 0.5), Vector3D.Unit.PLUS_X, TEST_PRECISION)
.segment(-10, 10));

LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.expect(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.and(Vector3D.of(0, 0.5, 0.5), Vector3D.Unit.MINUS_X)
.whenGiven(Line3D.fromPointAndDirection(Vector3D.of(0.5, 0.5, 0.5), Vector3D.Unit.MINUS_X, TEST_PRECISION)
.segment(-10, 10));
Expand All @@ -152,12 +152,12 @@ public void testLinecast_segment_boundaryExcluded() {
// act/assert
Vector3D center = Vector3D.of(0.5, 0.5, 0.5);
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.expect(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.whenGiven(Line3D.fromPointAndDirection(center, Vector3D.Unit.PLUS_X, TEST_PRECISION)
.segmentFrom(center));

LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.expect(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.whenGiven(Line3D.fromPointAndDirection(center, Vector3D.Unit.MINUS_X, TEST_PRECISION)
.segmentTo(center));
}
Expand All @@ -169,7 +169,7 @@ public void testLinecast_segment_startEndPointsOnBoundaries() {

// act/assert
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.expect(Vector3D.of(1, 0.5, 0.5), Vector3D.Unit.PLUS_X)
.and(Vector3D.of(0, 0.5, 0.5), Vector3D.Unit.MINUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(1, 0.5, 0.5), Vector3D.of(0, 0.5, 0.5), TEST_PRECISION));
}
Expand All @@ -183,18 +183,18 @@ public void testLinecast_segment_alongFace() {

// includes two intersecting boundaries
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(0, 1, 0), Vector3D.Unit.MINUS_X)
.expect(Vector3D.of(0, 1, 0), Vector3D.Unit.MINUS_X)
.and(Vector3D.of(1, 1, 0), Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(-1, 1, 0), Vector3D.of(2, 1, 0), TEST_PRECISION));

// one intersecting boundary
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(1, 1, 0), Vector3D.Unit.PLUS_X)
.expect(Vector3D.of(1, 1, 0), Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(0.25, 1, 0), Vector3D.of(2, 1, 0), TEST_PRECISION));

// no intersecting boundary
LinecastChecker3D.with(linecaster)
.returnsNothing()
.expectNothing()
.whenGiven(Segment3D.fromPoints(Vector3D.of(0.25, 1, 0), Vector3D.of(0.75, 1, 0), TEST_PRECISION));
}

Expand All @@ -209,21 +209,21 @@ public void testLinecast_segment_corners() {

// through corner
LinecastChecker3D.with(linecaster)
.returns(corner, Vector3D.Unit.PLUS_Z)
.expect(corner, Vector3D.Unit.PLUS_Z)
.and(corner, Vector3D.Unit.PLUS_Y)
.and(corner, Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(0.5, 0.5, 0.5), Vector3D.of(2, 2, 2), TEST_PRECISION));

// starts on corner
LinecastChecker3D.with(linecaster)
.returns(corner, Vector3D.Unit.PLUS_Z)
.expect(corner, Vector3D.Unit.PLUS_Z)
.and(corner, Vector3D.Unit.PLUS_Y)
.and(corner, Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(corner, Vector3D.of(2, 0, 2), TEST_PRECISION));

// ends on corner
LinecastChecker3D.with(linecaster)
.returns(corner, Vector3D.Unit.PLUS_Z)
.expect(corner, Vector3D.Unit.PLUS_Z)
.and(corner, Vector3D.Unit.PLUS_Y)
.and(corner, Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(0, 2, 2), corner, TEST_PRECISION));
Expand All @@ -240,7 +240,7 @@ public void testLinecast_segment_removesDuplicatePoints() {

// act/assert
LinecastChecker3D.with(linecaster)
.returns(Vector3D.of(0, 0.5, 0), Vector3D.Unit.PLUS_Z)
.expect(Vector3D.of(0, 0.5, 0), Vector3D.Unit.PLUS_Z)
.whenGiven(Segment3D.fromPoints(Vector3D.of(-1, 0.5, 1), Vector3D.of(1, 0.5, -1), TEST_PRECISION));
}
}
Expand Up @@ -222,11 +222,11 @@ public void testLinecast_full() {

// act/assert
LinecastChecker3D.with(volume)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPoints(Vector3D.ZERO, Vector3D.Unit.PLUS_X, TEST_PRECISION));

LinecastChecker3D.with(volume)
.returnsNothing()
.expectNothing()
.whenGiven(Segment3D.fromPoints(Vector3D.Unit.MINUS_X, Vector3D.Unit.PLUS_X, TEST_PRECISION));
}

Expand All @@ -237,11 +237,11 @@ public void testLinecast() {

// act/assert
LinecastChecker3D.with(volume)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPoints(Vector3D.of(0, 5, 5), Vector3D.of(1, 5, 5), TEST_PRECISION));

LinecastChecker3D.with(volume)
.returns(Vector3D.ZERO, Vector3D.Unit.MINUS_X)
.expect(Vector3D.ZERO, Vector3D.Unit.MINUS_X)
.and(Vector3D.ZERO, Vector3D.Unit.MINUS_Y)
.and(Vector3D.ZERO, Vector3D.Unit.MINUS_Z)
.and(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Z)
Expand All @@ -250,7 +250,7 @@ public void testLinecast() {
.whenGiven(Line3D.fromPoints(Vector3D.ZERO, Vector3D.of(1, 1, 1), TEST_PRECISION));

LinecastChecker3D.with(volume)
.returns(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Z)
.expect(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Z)
.and(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_Y)
.and(Vector3D.of(1, 1, 1), Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(0.5, 0.5, 0.5), Vector3D.of(1, 1, 1), TEST_PRECISION));
Expand Down
Expand Up @@ -51,7 +51,7 @@ class LinecastChecker3D {
* or {@link #whenGiven(Segment)}.
* @return
*/
public LinecastChecker3D returnsNothing() {
public LinecastChecker3D expectNothing() {
expectedResults.clear();

return this;
Expand All @@ -64,7 +64,7 @@ public LinecastChecker3D returnsNothing() {
* @param normal
* @return
*/
public LinecastChecker3D returns(final Vector3D point, final Vector3D normal) {
public LinecastChecker3D expect(final Vector3D point, final Vector3D normal) {
expectedResults.add(new ExpectedResult(point, normal));

return this;
Expand All @@ -76,7 +76,7 @@ public LinecastChecker3D returns(final Vector3D point, final Vector3D normal) {
* @return
*/
public LinecastChecker3D and(final Vector3D point, final Vector3D normal) {
return returns(point, normal);
return expect(point, normal);
}

/** Perform {@link Linecastable2D#linecast(Line)} and {@link Linecastable2D#linecastFirst(Line)}
Expand Down
Expand Up @@ -308,11 +308,11 @@ public void testLinecast_empty() {

// act/assert
LinecastChecker3D.with(tree)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPoints(Vector3D.ZERO, Vector3D.Unit.PLUS_X, TEST_PRECISION));

LinecastChecker3D.with(tree)
.returnsNothing()
.expectNothing()
.whenGiven(Segment3D.fromPoints(Vector3D.Unit.MINUS_X, Vector3D.Unit.PLUS_X, TEST_PRECISION));
}

Expand All @@ -323,11 +323,11 @@ public void testLinecast_full() {

// act/assert
LinecastChecker3D.with(tree)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPoints(Vector3D.ZERO, Vector3D.Unit.PLUS_X, TEST_PRECISION));

LinecastChecker3D.with(tree)
.returnsNothing()
.expectNothing()
.whenGiven(Segment3D.fromPoints(Vector3D.Unit.MINUS_X, Vector3D.Unit.PLUS_X, TEST_PRECISION));
}

Expand All @@ -338,13 +338,13 @@ public void testLinecast() {

// act/assert
LinecastChecker3D.with(tree)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPoints(Vector3D.of(0, 5, 5), Vector3D.of(1, 6, 6), TEST_PRECISION));

Vector3D corner = Vector3D.of(1, 1, 1);

LinecastChecker3D.with(tree)
.returns(Vector3D.ZERO, Vector3D.Unit.MINUS_X)
.expect(Vector3D.ZERO, Vector3D.Unit.MINUS_X)
.and(Vector3D.ZERO, Vector3D.Unit.MINUS_Y)
.and(Vector3D.ZERO, Vector3D.Unit.MINUS_Z)
.and(corner, Vector3D.Unit.PLUS_Z)
Expand All @@ -353,7 +353,7 @@ public void testLinecast() {
.whenGiven(Line3D.fromPoints(Vector3D.ZERO, corner, TEST_PRECISION));

LinecastChecker3D.with(tree)
.returns(corner, Vector3D.Unit.PLUS_Z)
.expect(corner, Vector3D.Unit.PLUS_Z)
.and(corner, Vector3D.Unit.PLUS_Y)
.and(corner, Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(0.5, 0.5, 0.5), corner, TEST_PRECISION));
Expand All @@ -368,13 +368,13 @@ public void testLinecast_complementedTree() {

// act/assert
LinecastChecker3D.with(tree)
.returnsNothing()
.expectNothing()
.whenGiven(Line3D.fromPoints(Vector3D.of(0, 5, 5), Vector3D.of(1, 6, 6), TEST_PRECISION));

Vector3D corner = Vector3D.of(1, 1, 1);

LinecastChecker3D.with(tree)
.returns(Vector3D.ZERO, Vector3D.Unit.PLUS_Z)
.expect(Vector3D.ZERO, Vector3D.Unit.PLUS_Z)
.and(Vector3D.ZERO, Vector3D.Unit.PLUS_Y)
.and(Vector3D.ZERO, Vector3D.Unit.PLUS_X)
.and(corner, Vector3D.Unit.MINUS_X)
Expand All @@ -383,7 +383,7 @@ public void testLinecast_complementedTree() {
.whenGiven(Line3D.fromPoints(Vector3D.ZERO, corner, TEST_PRECISION));

LinecastChecker3D.with(tree)
.returns(corner, Vector3D.Unit.MINUS_X)
.expect(corner, Vector3D.Unit.MINUS_X)
.and(corner, Vector3D.Unit.MINUS_Y)
.and(corner, Vector3D.Unit.MINUS_Z)
.whenGiven(Segment3D.fromPoints(Vector3D.of(0.5, 0.5, 0.5), corner, TEST_PRECISION));
Expand Down Expand Up @@ -414,7 +414,7 @@ public void testLinecast_complexRegion() {
Vector3D corner = Vector3D.of(1.5, 1.5, 1.5);

LinecastChecker3D.with(tree)
.returns(corner, Vector3D.Unit.PLUS_Z)
.expect(corner, Vector3D.Unit.PLUS_Z)
.and(corner, Vector3D.Unit.PLUS_Y)
.and(corner, Vector3D.Unit.PLUS_X)
.whenGiven(Segment3D.fromPoints(Vector3D.of(0.25, 0.25, 0.25), Vector3D.of(2, 2, 2), TEST_PRECISION));
Expand All @@ -429,11 +429,11 @@ public void testLinecast_removesDuplicatePoints() {

// act/assert
LinecastChecker3D.with(tree)
.returns(Vector3D.ZERO, Vector3D.Unit.PLUS_Y)
.expect(Vector3D.ZERO, Vector3D.Unit.PLUS_Y)
.whenGiven(Line3D.fromPoints(Vector3D.of(1, 1, 1), Vector3D.of(-1, -1, -1), TEST_PRECISION));

LinecastChecker3D.with(tree)
.returns(Vector3D.ZERO, Vector3D.Unit.PLUS_Y)
.expect(Vector3D.ZERO, Vector3D.Unit.PLUS_Y)
.whenGiven(Segment3D.fromPoints(Vector3D.of(1, 1, 1), Vector3D.of(-1, -1, -1), TEST_PRECISION));
}

Expand Down

0 comments on commit 0df749c

Please sign in to comment.