diff options
author | Andrey Loskutov <loskutov@gmx.de> | 2016-01-02 13:24:02 +0100 |
---|---|---|
committer | Andrey Loskutov <loskutov@gmx.de> | 2016-01-02 17:41:58 +0100 |
commit | d6deb190e61b9b891af2fe67198a18b4ddb2057f (patch) | |
tree | d4fe3e41057320b06043b938903143479f58fd4a /org.eclipse.jgit.pgm.test/src | |
parent | 35db319e8a10a26f08bad3f66ebf6f51008d9735 (diff) | |
download | jgit-d6deb190e61b9b891af2fe67198a18b4ddb2057f.tar.gz jgit-d6deb190e61b9b891af2fe67198a18b4ddb2057f.zip |
Simplify pgm tests: allow varargs and trim output for toString()
Change-Id: Ia5bcd9e560b90cf872fef75c2800c889ef1cc85a
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.pgm.test/src')
-rw-r--r-- | org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java index a72af9a1c4..a3436a0179 100644 --- a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java +++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java @@ -223,20 +223,24 @@ public class CLIRepositoryTestCase extends LocalDiskRepositoryTestCase { assertEquals(toString(expected), toString(actual)); } - public static String toString(String[] lines) { + public static String toString(String... lines) { return toString(Arrays.asList(lines)); } public static String toString(List<String> lines) { StringBuilder b = new StringBuilder(); for (String s : lines) { + // trim indentation, to simplify tests + s = s.trim(); if (s != null && !s.isEmpty()) { b.append(s); - if (!s.endsWith("\n")) { - b.append('\n'); - } + b.append('\n'); } } + // delete last line break to allow simpler tests with one line compare + if (b.length() > 0 && b.charAt(b.length() - 1) == '\n') { + b.deleteCharAt(b.length() - 1); + } return b.toString(); } |