From ef28875a8ef6db3f9601cc80f753197feb214606 Mon Sep 17 00:00:00 2001 From: Ahmed Ashour Date: Tue, 9 Apr 2019 18:02:04 +0200 Subject: [PATCH] test: add test case for #43 (PR #576) --- .../integration/loops/TestBreakInLoop3.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 jadx-core/src/test/java/jadx/tests/integration/loops/TestBreakInLoop3.java diff --git a/jadx-core/src/test/java/jadx/tests/integration/loops/TestBreakInLoop3.java b/jadx-core/src/test/java/jadx/tests/integration/loops/TestBreakInLoop3.java new file mode 100644 index 000000000..453f3c61d --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/loops/TestBreakInLoop3.java @@ -0,0 +1,61 @@ +package jadx.tests.integration.loops; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.File; +import java.io.FileOutputStream; + +import org.junit.jupiter.api.Test; + +import jadx.NotYetImplemented; +import jadx.tests.api.IntegrationTest; + +public class TestBreakInLoop3 extends IntegrationTest { + + public static class TestCls { + + private StringBuilder builder = new StringBuilder(); + + public void writeMore(String fid) { + boolean tryMkdir = true; + File ff = new File(fid); + while (true) { + prt("1"); + try { + new FileOutputStream(fid).close(); + } catch (Exception ex) { + if (tryMkdir) { // On first error, try creating the base dirs. + tryMkdir = false; + prt("2"); + continue; + } + prt("3"); + if (ff.exists()) { + prt("4"); + } else { + prt("5"); + } + prt("6"); + } + prt("7"); + break; + } // end of while true, loop to allow retry of fos.write after mkdir + prt("8"); + } // end of writeMore + + private void prt(String s) { + builder.append(s); + } + + public void check() { + writeMore(""); + assertEquals("12135678", builder.toString()); + } + } + + @Test + @NotYetImplemented + public void test43() throws Exception { + getClassNode(TestCls.class); + } +}