private static List<String> doDecode(Charset charset, Newline newline, List<Buffer> buffers) { return doDecode(charset, newline, null, buffers); }
private static LineDecoder newDecoder(Charset charset, Newline newline, List<Buffer> buffers) { return newDecoder(charset, newline, null, buffers); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeBasicAsciiCRLF() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.CRLF, bufferList(StandardCharsets.UTF_8, "test1\r\ntest2\r\ntest3\r\n")); assertEquals(ImmutableList.of("test1", "test2", "test3"), decoded); }
private static LineDecoder newDecoder(Charset charset, Newline newline, LineDelimiter lineDelimiter, List<Buffer> buffers) { ListFileInput input = new ListFileInput(ImmutableList.of(buffers)); return new LineDecoder(input, getExampleConfig(charset, newline, lineDelimiter)); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeChunksUTF8LF() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.LF, bufferList(StandardCharsets.UTF_8, "て", "1", "\n", "す", "2")); assertEquals(ImmutableList.of("て1", "す2"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeWithLineDelimiterRecognizedCRLF() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.CRLF, LineDelimiter.CRLF, bufferList(StandardCharsets.UTF_8, "test1\r\ntest2\rtest3\ntest4")); assertEquals(ImmutableList.of("test1", "test2\rtest3\ntest4"), decoded); } }
private static List<String> doDecode(Charset charset, Newline newline, LineDelimiter lineDelimiter, List<Buffer> buffers) { ImmutableList.Builder<String> builder = ImmutableList.builder(); LineDecoder decoder = newDecoder(charset, newline, lineDelimiter, buffers); decoder.nextFile(); while (true) { String line = decoder.poll(); if (line == null) { break; } builder.add(line); } return builder.build(); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeBasicUTF8() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.LF, bufferList(StandardCharsets.UTF_8, "てすと1\nテスト2\nてすと3\n")); assertEquals(ImmutableList.of("てすと1", "テスト2", "てすと3"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeBasicMS932Tail() throws Exception { List<String> decoded = doDecode( Charset.forName("ms932"), Newline.LF, bufferList(Charset.forName("ms932"), "てすと1")); assertEquals(ImmutableList.of("てすと1"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeChunksMS932LF() throws Exception { List<String> decoded = doDecode( Charset.forName("ms932"), Newline.LF, bufferList(Charset.forName("ms932"), "て", "1", "\n", "す", "2")); assertEquals(ImmutableList.of("て1", "す2"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeChunksMS932CRLF() throws Exception { List<String> decoded = doDecode( Charset.forName("ms932"), Newline.CRLF, bufferList(Charset.forName("ms932"), "て", "1", "\r\n", "す", "2", "\r", "\n", "と3")); assertEquals(ImmutableList.of("て1", "す2", "と3"), decoded); }
@Test public void testDecodeBasicAsciiTail() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.LF, bufferList(StandardCharsets.UTF_8, "test1")); assertEquals(ImmutableList.of("test1"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeChunksCRLF() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.CRLF, bufferList(StandardCharsets.UTF_8, "t", "1", "\r\n", "t", "2", "\r", "\n", "t3")); assertEquals(ImmutableList.of("t1", "t2", "t3"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeBasicUTF8Tail() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.LF, bufferList(StandardCharsets.UTF_8, "てすと1")); assertEquals(ImmutableList.of("てすと1"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeBasicUTF16LETail() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_16LE, Newline.LF, bufferList(StandardCharsets.UTF_16LE, "てすと1")); assertEquals(ImmutableList.of("てすと1"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeWithLineDelimiterRecognizedLF() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.CRLF, LineDelimiter.LF, bufferList(StandardCharsets.UTF_8, "test1\r\ntest2\rtest3\ntest4")); assertEquals(ImmutableList.of("test1\r\ntest2\rtest3", "test4"), decoded); }
@Test public void testDecodeBasicAscii() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.LF, bufferList(StandardCharsets.UTF_8, "test1\ntest2\ntest3\n")); assertEquals(ImmutableList.of("test1", "test2", "test3"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeChunksLF() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_8, Newline.LF, bufferList(StandardCharsets.UTF_8, "t", "1", "\n", "t", "2")); assertEquals(ImmutableList.of("t1", "t2"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeChunksUTF16LELF() throws Exception { List<String> decoded = doDecode( StandardCharsets.UTF_16LE, Newline.LF, bufferList(StandardCharsets.UTF_16LE, "て", "1", "\n", "す", "2")); assertEquals(ImmutableList.of("て1", "す2"), decoded); }
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") @Test public void testDecodeBasicMS932() throws Exception { List<String> decoded = doDecode( Charset.forName("ms932"), Newline.LF, bufferList(Charset.forName("ms932"), "てすと1\nテスト2\nてすと3\n")); assertEquals(ImmutableList.of("てすと1", "テスト2", "てすと3"), decoded); }