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:
parent
3809b05556
commit
a9388f9f8f
3
.gitignore
vendored
3
.gitignore
vendored
@ -16,6 +16,7 @@ hs_err_pid*.log
|
|||||||
rapport/
|
rapport/
|
||||||
!rapport/rapport.tex
|
!rapport/rapport.tex
|
||||||
!rapport/pics/*.png
|
!rapport/pics/*.png
|
||||||
|
!rapport/pics/*.PNG
|
||||||
!rapport/pics/*.jpg
|
!rapport/pics/*.jpg
|
||||||
|
|
||||||
# javadoc files
|
# javadoc files
|
||||||
@ -26,4 +27,4 @@ build/
|
|||||||
|
|
||||||
# tests files
|
# tests files
|
||||||
|
|
||||||
result.txt
|
test*.txt
|
@ -58,7 +58,8 @@
|
|||||||
<junit printsummary="true" haltonerror="no" haltonfailure="no" showoutput="true">
|
<junit printsummary="true" haltonerror="no" haltonfailure="no" showoutput="true">
|
||||||
<classpath refid="project.classpath"/>
|
<classpath refid="project.classpath"/>
|
||||||
<formatter type="plain"/>
|
<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>
|
</junit>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
@ -55,7 +55,7 @@ public class Rewrite {
|
|||||||
System.out.println(i + " / " + recurrences + " : " + rewritten.length());
|
System.out.println(i + " / " + recurrences + " : " + rewritten.length());
|
||||||
}
|
}
|
||||||
rewritten = rewritten.replace("[", "Y[");
|
rewritten = rewritten.replace("[", "Y[");
|
||||||
System.out.println(rewritten);
|
// System.out.println(rewritten);
|
||||||
return rewritten;
|
return rewritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
test/lsystem/StressTest.java
Normal file
30
test/lsystem/StressTest.java
Normal 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user