Browse Source

Fix FP in encoding detection test

tags/6.6-RC1
Duarte Meneses 7 years ago
parent
commit
4402772733

+ 13
- 1
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java View 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);

Loading…
Cancel
Save