]> source.dussan.org Git - sonarqube.git/commitdiff
Fix FP in encoding detection test
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 4 Jul 2017 12:05:36 +0000 (14:05 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 22 Aug 2017 07:26:45 +0000 (09:26 +0200)
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java

index 0da6349119bcfb1170399bc5c320122e25a63119..490d5d5f9a8ff553eabbe936f56b521364556b6d 100644 (file)
@@ -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);