void (boolean testCharByCharProcessing, @NotNull List<ColoredText> texts) { AnsiEscapeDecoder decoder = new AnsiEscapeDecoder(); List<Pair<String, String>> actualColoredChunks = new ArrayList<>(); AnsiEscapeDecoder.ColoredTextAcceptor acceptor = (text, attributes) -> { ProcessOutputType processOutputType = (ProcessOutputType)attributes; String escapeSequence = processOutputType.getEscapeSequence(); String outputType = escapeSequence != null ? escapeSequence : processOutputType.getBaseOutputType().toString(); actualColoredChunks.add(Pair.create(text, StringUtil.trimStart(outputType, "\u001b[0;"))); }; for (ColoredText text : texts) { decoder.escapeText(text.myRawText, text.myOutputType, acceptor); } List<Pair<String, String>> expectedColoredChunks = new ArrayList<>(); for (ColoredText text : texts) { expectedColoredChunks.addAll(text.myExpectedColoredChunks); } Assert.assertEquals(expectedColoredChunks, actualColoredChunks); if (testCharByCharProcessing) { // test stdout char by char actualColoredChunks.clear(); decoder = new AnsiEscapeDecoder(); for (ColoredText text : texts) { for (int i = 0; i < text.myRawText.length(); i++) { decoder.escapeText(String.valueOf(text.myRawText.charAt(i)), text.myOutputType, acceptor); } } expectedColoredChunks.clear(); for (ColoredText text : texts) { for (Pair<String, String> chunk : text.myExpectedColoredChunks) { String chunkText = chunk.first; for (int i = 0; i < chunkText.length(); i++) { expectedColoredChunks.add(Pair.create(String.valueOf(chunkText.charAt(i)), chunk.second)); } } } Assert.assertEquals(expectedColoredChunks, actualColoredChunks); } }