From 87223dba21384ca362e646d6d8752ea96bb0b561 Mon Sep 17 00:00:00 2001 From: Lars Eckart Date: Mon, 20 Nov 2023 20:58:09 +0200 Subject: [PATCH] - r prepare to replace tab --- .../org/approvaltests/inline/InlineJavaReporter.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/approvaltests/src/main/java/org/approvaltests/inline/InlineJavaReporter.java b/approvaltests/src/main/java/org/approvaltests/inline/InlineJavaReporter.java index 0ecc544d..0adbb70e 100644 --- a/approvaltests/src/main/java/org/approvaltests/inline/InlineJavaReporter.java +++ b/approvaltests/src/main/java/org/approvaltests/inline/InlineJavaReporter.java @@ -39,6 +39,7 @@ public String createReceived(String actual) } public static String createNewReceivedFileText(String text, String actual, String methodName) { + String tab = "\t"; text = text.replaceAll("\r\n", "\n"); int start = text.indexOf("void " + methodName + "("); start = text.indexOf("{", start); @@ -57,17 +58,17 @@ public static String createNewReceivedFileText(String text, String actual, Strin { part2 = text.substring(next + 1); } - String fullText = String.format("%s\n\t\tvar expected = \"\"\"\n%s\t\t\"\"\";\n%s", part1, indent(actual), - part2); + String fullText = String.format("%s\n%s%svar expected = \"\"\"\n%s%s%s\"\"\";\n%s", part1, tab, tab, + indent(actual, tab), tab, tab, part2); return fullText; } - public static String indent(String actual) + public static String indent(String actual, String tab) { String[] split = actual.split("\n"); String output = ""; for (String line : split) { - output += "\t\t" + line + "\n"; + output += tab + tab + line + "\n"; } return output; }