From 10fb57f6fb64f3786b7d868c8ee36e11db776aec Mon Sep 17 00:00:00 2001 From: Ahmed Ashour Date: Tue, 9 Apr 2019 17:45:40 +0200 Subject: [PATCH] test: add test case for #101 (PR #577) --- .../trycatch/TestTryWithResources.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithResources.java diff --git a/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithResources.java b/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithResources.java new file mode 100644 index 000000000..a3e98bc8c --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithResources.java @@ -0,0 +1,39 @@ +package jadx.tests.integration.trycatch; + +import static jadx.tests.api.utils.JadxMatchers.containsOne; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.junit.jupiter.api.Test; + +import jadx.NotYetImplemented; +import jadx.core.dex.nodes.ClassNode; +import jadx.tests.api.SmaliTest; + +public class TestTryWithResources extends SmaliTest { + + public static class TestCls { + + public static void writeFully(File file, byte[] data) throws IOException { + try (OutputStream out = new FileOutputStream(file)) { + out.write(data); + } + } + } + + @Test + @NotYetImplemented + public void test() { + ClassNode cls = getClassNode(TestCls.class); + String code = cls.getCode().toString(); + + assertThat(code, containsOne("try (")); + assertThat(code, not(containsString("close()"))); + } +}