From 8a8290d609c086a7e265bd7d88c92580a9d9890f Mon Sep 17 00:00:00 2001 From: Constantine Plotnikov Date: Mon, 16 Feb 2009 20:46:31 +0300 Subject: [PATCH] Fix invalid quoted string test preventing a build under Maven The test was failing on a system that uses an encoding different from ISO-8859-1. The reason was that invalid UTF-8 bytes were generated for codepoints greater than U+7F, and in this case the method RawParseUtils.decodeNoFallback() falls backs to the default system encoding. Signed-off-by: Constantine Plotnikov Signed-off-by: Shawn O. Pearce --- .../jgit/util/QuotedStringGitPathStyleTest.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/QuotedStringGitPathStyleTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/QuotedStringGitPathStyleTest.java index 54fbd315..7d29f21e 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/QuotedStringGitPathStyleTest.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/QuotedStringGitPathStyleTest.java @@ -127,13 +127,22 @@ public class QuotedStringGitPathStyleTest extends TestCase { } public void testDequote_OctalAll() { - for (int i = 0; i < 256; i++) { - String s = Integer.toOctalString(i); - while (s.length() < 3) { - s = "0" + s; - } - assertDequote("" + (char) i, "\\" + s); + for (int i = 0; i < 127; i++) { + assertDequote("" + (char) i, octalEscape(i)); } + for (int i = 128; i < 256; i++) { + int f = 0xC0 | (i >> 6); + int s = 0x80 | (i & 0x3f); + assertDequote("" + (char) i, octalEscape(f)+octalEscape(s)); + } + } + + private String octalEscape(int i) { + String s = Integer.toOctalString(i); + while (s.length() < 3) { + s = "0" + s; + } + return "\\"+s; } public void testQuote_OctalAll() { -- 2.11.4.GIT