Skip to content
Snippets Groups Projects
Commit 0fff625f authored by Vetle Solheim Hodne's avatar Vetle Solheim Hodne
Browse files

Fixed error in one chaosgame-testmethod.

parent 29372ee9
No related branches found
No related tags found
1 merge request!20Created test classes for Factory and FileReader. Created equals methods
Pipeline #288053 passed
......@@ -143,8 +143,9 @@ public class ChaosGame implements Subject {
/**
* Method for running the chaos game. Randomly selects a transformation
* from the description and applies it to the current point.
* Method for running the chaos game.
* Selects which runSteps method to use based if it has a list of probabilities.
* Notifies observers after running the steps.
*/
public void runSteps() {
if (description.getProbabilities() != null) {
......@@ -155,6 +156,10 @@ public class ChaosGame implements Subject {
notifyObservers();
}
/**
* Method for running the chaos game. Randomly selects a transformation
* from the description and applies it to the current point.
*/
private void runStepsUniform(int steps) {
for (int i = 0; i < steps; i++) {
int transformIndex = random.nextInt(description.getTransforms().size());
......
......@@ -42,6 +42,8 @@ class ChaosGameTest {
@BeforeEach
void init() {
instance = ChaosGame.getInstance(juliaDescription, 500, 500);
instance.setSteps(0);
instance.setTotalSteps(0);
}
@Nested
......@@ -119,37 +121,23 @@ class ChaosGameTest {
@Test
void addTotalSteps() {
instance.addTotalSteps(10);
assertEquals(10, instance.getTotalSteps(), "The total steps should be 10");
instance.addTotalSteps(10);
assertEquals(20, instance.getTotalSteps(), "The total steps should be 10");
}
@Test
void resetTotalSteps() {
instance.addTotalSteps(10);
instance.resetTotalSteps();
assertEquals(0, instance.getTotalSteps(), "The total steps should be 0");
}
}
@Test
void setSteps() {
}
@Test
void setTotalSteps() {
}
@Test
void addTotalSteps() {
}
@Test
void resetTotalSteps() {
}
@Test
void runSteps() {
@Test
void runSteps() {
instance.setSteps(10);
instance.runSteps();
assertEquals(10, instance.getSteps(), "The total steps should be 10");
}
}
@Test
......@@ -159,4 +147,5 @@ class ChaosGameTest {
@Test
void setChaosCanvas() {
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment