From a9388f9f8fdd90680baf578e2a011ae992fee8d4 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Tue, 20 Apr 2021 15:15:10 +0200 Subject: [PATCH] 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 --- .gitignore | 3 ++- build.xml | 3 ++- src/lsystem/engine/Rewrite.java | 2 +- test/lsystem/StressTest.java | 30 ++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test/lsystem/StressTest.java diff --git a/.gitignore b/.gitignore index d661493..c5221dd 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +test*.txt \ No newline at end of file diff --git a/build.xml b/build.xml index fb82d50..1b655db 100644 --- a/build.xml +++ b/build.xml @@ -58,7 +58,8 @@ - + + \ No newline at end of file diff --git a/src/lsystem/engine/Rewrite.java b/src/lsystem/engine/Rewrite.java index c85be8d..fe1454a 100644 --- a/src/lsystem/engine/Rewrite.java +++ b/src/lsystem/engine/Rewrite.java @@ -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; } diff --git a/test/lsystem/StressTest.java b/test/lsystem/StressTest.java new file mode 100644 index 0000000..1c86829 --- /dev/null +++ b/test/lsystem/StressTest.java @@ -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> 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()); + } + +}