freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [3/4] incubator-freemarker git commit: ASTTest: Ensure loaded template uses LF-s instead of replacing \r\n-s later in string literals
Date Fri, 16 Oct 2015 19:26:52 GMT
ASTTest: Ensure loaded template uses LF-s instead of replacing \r\n-s later in string literals


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/0256df53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/0256df53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/0256df53

Branch: refs/heads/2.3
Commit: 0256df536e130bfccd193bdbb0a41245431890ac
Parents: 597a450
Author: ddekany <ddekany@apache.org>
Authored: Fri Oct 16 21:25:50 2015 +0200
Committer: ddekany <ddekany@apache.org>
Committed: Fri Oct 16 21:25:50 2015 +0200

----------------------------------------------------------------------
 src/test/java/freemarker/core/ASTTest.java              | 7 ++++++-
 src/test/java/freemarker/test/utility/FileTestCase.java | 8 ++------
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0256df53/src/test/java/freemarker/core/ASTTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/ASTTest.java b/src/test/java/freemarker/core/ASTTest.java
index 1f3f53d..6ba4378 100644
--- a/src/test/java/freemarker/core/ASTTest.java
+++ b/src/test/java/freemarker/core/ASTTest.java
@@ -22,6 +22,7 @@ package freemarker.core;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import freemarker.template.utility.StringUtil;
 import freemarker.test.utility.FileTestCase;
 
 public class ASTTest extends FileTestCase {
@@ -62,7 +63,11 @@ public class ASTTest extends FileTestCase {
         final String templateName = testName + ".ftl";
         assertExpectedFileEqualsString(
                 testName + ".ast",
-                ASTPrinter.getASTAsString(templateName, loadResource(templateName)));
+                ASTPrinter.getASTAsString(templateName, normalizeLineBreaks(templateName)));
+    }
+
+    private String normalizeLineBreaks(final String templateName) throws FileNotFoundException,
IOException {
+        return StringUtil.replace(loadResource(templateName), "\r\n", "\n").replace('\r',
'\n');
     }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0256df53/src/test/java/freemarker/test/utility/FileTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/test/utility/FileTestCase.java b/src/test/java/freemarker/test/utility/FileTestCase.java
index e2d8938..66e9565 100644
--- a/src/test/java/freemarker/test/utility/FileTestCase.java
+++ b/src/test/java/freemarker/test/utility/FileTestCase.java
@@ -87,8 +87,8 @@ public abstract class FileTestCase extends TestCase {
     }
 
     private void multilineAssertEquals(String expected, String actual) {
-        String normExpected = normalizeNewLineLiterals(normalizeNewLines(expected));
-        final String normActual = normalizeNewLineLiterals(normalizeNewLines(actual));
+        String normExpected = normalizeNewLines(expected);
+        final String normActual = normalizeNewLines(actual);
         
         // Ignore final line-break difference:
         if (normActual.endsWith("\n") && !normExpected.endsWith("\n")) {
@@ -100,10 +100,6 @@ public abstract class FileTestCase extends TestCase {
         assertEquals(normExpected, normActual);
     }
 
-    private String normalizeNewLineLiterals(String s) {
-        return StringUtil.replace(s, "\\r\\n", "\\n");
-    }
-
     private String normalizeNewLines(String s) {
         return StringUtil.replace(s, "\r\n", "\n").replace('\r', '\n');
     }


Mime
View raw message