test: add core unit tests

- Add JUnit 5 Jupiter dependencies to pom.xml
- Add maven-surefire-plugin for test execution
- Add AbstractShapeTest for base class methods
- Add SCircleTest, SRectangleTest, STriangleTest, STextTest

Tests cover: creation, bounds, clone, resize (AbstractShape)
This commit is contained in:
2026-03-27 00:16:09 +01:00
parent b0e3428696
commit 211f15658b
6 changed files with 278 additions and 3 deletions

View File

@@ -0,0 +1,37 @@
package ovh.gasser.newshapes.shapes;
import org.junit.jupiter.api.Test;
import java.awt.Color;
import java.awt.Rectangle;
import static org.junit.jupiter.api.Assertions.*;
class STriangleTest {
@Test
void testCreate() {
STriangle triangle = STriangle.create(10, 20, 50, Color.RED, Color.BLACK);
assertNotNull(triangle);
assertEquals(50, triangle.getBounds().width);
assertEquals(50, triangle.getBounds().height);
}
@Test
void testCloneCreatesIndependentCopy() {
STriangle original = STriangle.create(0, 0, 30, Color.BLUE, Color.BLACK);
Object cloneObj = original.clone();
assertNotSame(original, cloneObj);
assertTrue(cloneObj instanceof STriangle);
STriangle clone = (STriangle) cloneObj;
assertEquals(original.getBounds(), clone.getBounds());
}
@Test
void testBoundsAreSetCorrectly() {
STriangle triangle = STriangle.create(5, 10, 25, Color.GREEN, Color.BLACK);
Rectangle bounds = triangle.getBounds();
assertEquals(5, bounds.x);
assertEquals(10, bounds.y);
assertEquals(25, bounds.width);
assertEquals(25, bounds.height);
}
}