summaryrefslogtreecommitdiffstats
path: root/test/org
diff options
context:
space:
mode:
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-09-12 19:26:15 +0400
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-09-12 19:26:15 +0400
commite1d1425f22724b105f7c710838196cec1f9ff06d (patch)
tree4cd1df5b44ae0d20d447bc4cf442f06e10ee9369 /test/org
parente90f1de039b9305eed038f58db773ac2b8be36ed (diff)
downloadfernflower-e1d1425f22724b105f7c710838196cec1f9ff06d.tar
fernflower-e1d1425f22724b105f7c710838196cec1f9ff06d.tar.gz
fernflower-e1d1425f22724b105f7c710838196cec1f9ff06d.tar.lz
fernflower-e1d1425f22724b105f7c710838196cec1f9ff06d.tar.xz
fernflower-e1d1425f22724b105f7c710838196cec1f9ff06d.zip
java-decompiler: fix for broken Git checkout on Windows
Diffstat (limited to 'test/org')
-rw-r--r--test/org/jetbrains/java/decompiler/SingleClassesTest.java26
1 files changed, 10 insertions, 16 deletions
diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java
index 70aa605..2443c64 100644
--- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java
+++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java
@@ -16,6 +16,7 @@
package org.jetbrains.java.decompiler;
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
+import org.jetbrains.java.decompiler.util.InterpreterUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -79,9 +80,7 @@ public class SingleClassesTest {
File referenceFile = new File(fixture.getTestDataDir(), "results/" + testName + ".dec");
assertTrue(referenceFile.isFile());
- String decompiledContent = getContent(decompiledFile);
- String referenceContent = getContent(referenceFile);
- assertEquals(referenceContent, decompiledContent);
+ compareContent(decompiledFile, referenceFile);
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -107,19 +106,14 @@ public class SingleClassesTest {
return files;
}
- private static String getContent(File file) throws IOException {
- Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8");
- try {
- char[] buff = new char[16 * 1024];
- StringBuilder content = new StringBuilder();
- int n;
- while ((n = reader.read(buff)) > 0) {
- content.append(buff, 0, n);
- }
- return content.toString();
- }
- finally {
- reader.close();
+ private static void compareContent(File decompiledFile, File referenceFile) throws IOException {
+ String decompiledContent = new String(InterpreterUtil.getBytes(decompiledFile), "UTF-8");
+
+ String referenceContent = new String(InterpreterUtil.getBytes(referenceFile), "UTF-8");
+ if (InterpreterUtil.IS_WINDOWS && !referenceContent.contains("\r\n")) {
+ referenceContent = referenceContent.replace("\n", "\r\n"); // fix for broken Git checkout on Windows
}
+
+ assertEquals(referenceContent, decompiledContent);
}
}