Replacing deprecated IO methods with ones that specify a charset
Standardizing with StandardCharsets.UTF_8, given that it was used in several places of code already, and it provides compile-time checking (as opposed to "UTF-8")
This commit is contained in:
@ -8,6 +8,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@ -67,21 +68,21 @@ public class CPPTokenizerTest {
|
||||
|
||||
@Test
|
||||
public void testTokenizerWithSkipBlocks() throws Exception {
|
||||
String test = IOUtils.toString(CPPTokenizerTest.class.getResourceAsStream("cpp/cpp_with_asm.cpp"));
|
||||
String test = IOUtils.toString(CPPTokenizerTest.class.getResourceAsStream("cpp/cpp_with_asm.cpp"), StandardCharsets.UTF_8);
|
||||
Tokens tokens = parse(test, true);
|
||||
assertEquals(19, tokens.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTokenizerWithSkipBlocksPattern() throws Exception {
|
||||
String test = IOUtils.toString(CPPTokenizerTest.class.getResourceAsStream("cpp/cpp_with_asm.cpp"));
|
||||
String test = IOUtils.toString(CPPTokenizerTest.class.getResourceAsStream("cpp/cpp_with_asm.cpp"), StandardCharsets.UTF_8);
|
||||
Tokens tokens = parse(test, true, "#if debug|#endif");
|
||||
assertEquals(31, tokens.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTokenizerWithoutSkipBlocks() throws Exception {
|
||||
String test = IOUtils.toString(CPPTokenizerTest.class.getResourceAsStream("cpp/cpp_with_asm.cpp"));
|
||||
String test = IOUtils.toString(CPPTokenizerTest.class.getResourceAsStream("cpp/cpp_with_asm.cpp"), StandardCharsets.UTF_8);
|
||||
Tokens tokens = parse(test, false);
|
||||
assertEquals(37, tokens.size());
|
||||
}
|
||||
|
Reference in New Issue
Block a user