add another test + delete sout in rewrite that can cause an OutOFMemoryError or/and an heavy consumption of your cpu if word is very long

This commit is contained in:
Quentin Legot 2021-04-20 15:15:10 +02:00
parent 3809b05556
commit a9388f9f8f
4 changed files with 35 additions and 3 deletions

3
.gitignore vendored
View File

@ -16,6 +16,7 @@ hs_err_pid*.log
rapport/
!rapport/rapport.tex
!rapport/pics/*.png
!rapport/pics/*.PNG
!rapport/pics/*.jpg
# javadoc files
@ -26,4 +27,4 @@ build/
# tests files
result.txt
test*.txt

View File

@ -58,7 +58,8 @@
<junit printsummary="true" haltonerror="no" haltonfailure="no" showoutput="true">
<classpath refid="project.classpath"/>
<formatter type="plain"/>
<test fork="true" name="lsystem.TestLSystem" outfile="result" />
<test fork="true" name="lsystem.TestLSystem" outfile="test1" />
<test fork="true" name="lsystem.StressTest" outfile="test2" />
</junit>
</target>
</project>

View File

@ -55,7 +55,7 @@ public class Rewrite {
System.out.println(i + " / " + recurrences + " : " + rewritten.length());
}
rewritten = rewritten.replace("[", "Y[");
System.out.println(rewritten);
// System.out.println(rewritten);
return rewritten;
}

View File

@ -0,0 +1,30 @@
package lsystem;
import lsystem.engine.Parser;
import lsystem.screen.gl3d.GLCanvas;
import lsystem.utils.Pair;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertNotNull;
public class StressTest {
/**
* require at least 1GB of free ram
*/
@Test
public void stressTest1() {
long millis = System.currentTimeMillis();
GLCanvas joglFrame = new GLCanvas();
Parser parser = new Parser("Y", Arrays.asList("Y=X+[[Y]-Y]-X[-XY]+Y", "X=XX"), 12);
List<Pair<String, String>> lSystemRules = parser.parseRules();
joglFrame.setLSystem(parser.getAxiom(), lSystemRules, parser.getNbIterations());
System.out.println(joglFrame.getLSystem());
System.out.println("time in millisecondes: " + (System.currentTimeMillis() - millis));
assertNotNull("L-System should not be null", joglFrame.getLSystem());
}
}