Add parameterized ShapeContractTest for Shape interface invariants
All checks were successful
CI / build-and-test (pull_request) Successful in 18s
All checks were successful
CI / build-and-test (pull_request) Successful in 18s
Verify clone(), getBounds(), and translate() contracts across all Shape implementations (SRectangle, SCircle, STriangle, SText, SCollection) using @ParameterizedTest + @MethodSource. Also adds junit-jupiter-params dependency to pom.xml. Closes #8
This commit is contained in:
25
src/test/java/ovh/gasser/newshapes/shapes/ShapeFactory.java
Normal file
25
src/test/java/ovh/gasser/newshapes/shapes/ShapeFactory.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package ovh.gasser.newshapes.shapes;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Provides Shape instances for parameterized contract tests.
|
||||
*/
|
||||
public final class ShapeFactory {
|
||||
|
||||
private ShapeFactory() {}
|
||||
|
||||
static Stream<Shape> allShapes() {
|
||||
return Stream.of(
|
||||
SRectangle.create(10, 20, 100, 50),
|
||||
SCircle.create(5, 5, 30),
|
||||
STriangle.create(0, 0, 40, Color.RED, Color.BLACK),
|
||||
SText.create(15, 25, "Hello"),
|
||||
SCollection.of(
|
||||
SRectangle.create(0, 0, 20, 20),
|
||||
SCircle.create(10, 10, 5)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user