From 440277273355aa69d0df7996d6135f1e2fa7b7bf Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Tue, 4 Jul 2017 14:05:36 +0200 Subject: [PATCH] Fix FP in encoding detection test --- .../scan/filesystem/CharsetDetectorTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java index 0da6349119b..490d5d5f9a8 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java @@ -94,8 +94,20 @@ public class CharsetDetectorTest { @Test public void no_encoding_found() throws IOException { Path filePath = temp.newFile().toPath(); - byte[] b = new byte[512]; + byte[] b = new byte[4096]; new Random().nextBytes(b); + // avoid accidental BOM matching + b[0] = 1; + + // avoid UTF-8 / UTF-16 + b[100] = 0; + b[101] = 0; + b[102] = 0; + b[103] = 0; + + // invalid in win-1258 + b[200] = (byte) 129; + Files.write(filePath, b); CharsetDetector detector = new CharsetDetector(filePath, UTF_8); -- 2.39.5