diff --git a/src/main/java/org/example/chaosgame/model/linalg/Vector2D.java b/src/main/java/org/example/chaosgame/model/linalg/Vector2D.java index 720f5353f5fde6211ed4e1b885c36b845591ec5c..daed3404327d29f10fe403ebfc0fc3712202ee62 100644 --- a/src/main/java/org/example/chaosgame/model/linalg/Vector2D.java +++ b/src/main/java/org/example/chaosgame/model/linalg/Vector2D.java @@ -102,15 +102,6 @@ public class Vector2D { } - /** - * Equals method for Vector2D. - * Compares two vectors for equality. - * Overrides the default equals method. - * Generated by IntelliJ IDEA. - * - * @param o Object to compare - * @return true if the vectors are equal, false otherwise - */ @Override public boolean equals(Object o) { if (this == o) return true; @@ -119,13 +110,6 @@ public class Vector2D { return Double.compare(x, vector2D.x) == 0 && Double.compare(y, vector2D.y) == 0; } - /** - * Hashcode method for Vector2D. - * Overrides the default hashcode method. - * Generated by IntelliJ IDEA. - * - * @return the hashcode of the vector - */ @Override public int hashCode() { return Objects.hash(x, y); diff --git a/src/test/java/org/example/chaosgame/model/chaos/ChaosGameDescriptionTest.java b/src/test/java/org/example/chaosgame/model/chaos/ChaosGameDescriptionTest.java index 3564dad37e3f07c4f6fdc0837d6f39891556b3e8..8dda796f14db9098c2a222ef6b3b24bb774ed8be 100644 --- a/src/test/java/org/example/chaosgame/model/chaos/ChaosGameDescriptionTest.java +++ b/src/test/java/org/example/chaosgame/model/chaos/ChaosGameDescriptionTest.java @@ -92,11 +92,11 @@ class ChaosGameDescriptionTest { @Test void testEquals() { ChaosGameDescription sameChaosGameDescription = new ChaosGameDescription(minCoords, maxCoords, transforms, probabilities); - assertTrue(chaosGameDescription.equals(sameChaosGameDescription)); - assertFalse(chaosGameDescription == null); + assertEquals(chaosGameDescription, sameChaosGameDescription); + assertNotNull(chaosGameDescription); assertNotEquals(chaosGameDescription, new Object()); ChaosGameDescription differentChaosGameDescription = new ChaosGameDescription(new Vector2D(1, 1), new Vector2D(2, 2), transforms, probabilities); - assertFalse(chaosGameDescription.equals(differentChaosGameDescription)); + assertNotEquals(chaosGameDescription, differentChaosGameDescription); } @Test diff --git a/src/test/java/org/example/chaosgame/model/linalg/Vector2DTest.java b/src/test/java/org/example/chaosgame/model/linalg/Vector2DTest.java index 3f177bd90a19389a6cad105157b06ab297e08c5b..3d432956948a6ea1985ddd1c3c3e02d6d9fd85a2 100644 --- a/src/test/java/org/example/chaosgame/model/linalg/Vector2DTest.java +++ b/src/test/java/org/example/chaosgame/model/linalg/Vector2DTest.java @@ -136,7 +136,7 @@ class Vector2DTest { @DisplayName("Test length should work") void length() { double l = vector.lengthSq(); - assertEquals(2.23606797749979, l); + assertEquals(5.0, l); } @Test diff --git a/src/test/java/org/example/chaosgame/model/transformations/ExploreJuliaTest.java b/src/test/java/org/example/chaosgame/model/transformations/ExploreJuliaTest.java index 4c7a0142bfae56bea29eb2c6b65cf63d8134803d..55900355656ec5fd5f0d02927ff67eb57adb5392 100644 --- a/src/test/java/org/example/chaosgame/model/transformations/ExploreJuliaTest.java +++ b/src/test/java/org/example/chaosgame/model/transformations/ExploreJuliaTest.java @@ -1,16 +1,48 @@ package org.example.chaosgame.model.transformations; -import org.junit.jupiter.api.Test; +import org.example.chaosgame.model.linalg.Complex; +import org.example.chaosgame.model.linalg.Vector2D; +import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; class ExploreJuliaTest { + private ExploreJulia exploreJulia; + private Complex complexPoint; - @Test - void getComplex() { + @BeforeEach + void setUp() { + complexPoint = new Complex(0.355, 0.355); + exploreJulia = new ExploreJulia(complexPoint); + } + + @AfterEach + void tearDown() { + complexPoint = null; + exploreJulia = null; } @Test - void transform() { + void testGetComplex() { + assertEquals(complexPoint, exploreJulia.getComplex()); + } + @Nested + @DisplayName("Test transforms") + class TestTransforms { + @Test + @DisplayName("Test positive transform") + void testTransform() { + Vector2D point = new Vector2D(0.5, 0.5); + Vector2D transformedPoint = exploreJulia.transform(point); + assertEquals(new Vector2D(0.355, 0.855), transformedPoint); + } + + @Test + @DisplayName("Test negative transform") + void testTransformFail() { + Vector2D point = new Vector2D(-0.5, -0.5); + Vector2D transformedPoint = exploreJulia.transform(point); + assertNotEquals(new Vector2D(0.355, -0.145), transformedPoint); + } } -} \ No newline at end of file +}