Buffer { public void insert(Consumer<int[]> out, int[] data, int width) { doInsert(data); printInsertedData(out, width); } Buffer();   Buffer(Prompt prompt);  Buffer(Buffer buf); CursorLocator getCursorLocator(); int get(int pos); int cursor(); int multiCursor(); boolean isMasking(); boolean isMultiLine(); String asString(); void reset(); void setIsPromptDisplayed(boolean isPromptDisplayed); void forceSetDeltaChangedAtEndOfBuffer(boolean delta); void disablePrompt(boolean disable); boolean isPromptDisabled(); Prompt prompt(); int length(); void setMultiLine(boolean multi); void invalidateCursorLocation(); void updateMultiLineBuffer(); void insert(Consumer<int[]> out, int[] data, int width); void insert(Consumer<int[]> out, int data, int width); void move(Consumer<int[]> out,  int move, int termWidth); void move(Consumer<int[]> out, int move, int termWidth, boolean viMode); static int[] moveNumberOfColumns(int column, char direction); int[] getLineMasked(); void clear(); void replace(Consumer<int[]> out, String line, int width); void replace(Consumer<int[]> out, int[] line, int width); int[] multiLine(); void delete(Consumer<int[]> out, int delta, int width); void delete(Consumer<int[]> out, int delta, int width, boolean viMode); void insert(Consumer<int[]> out, final String str, int width); void replace(Consumer<int[]> out, char rChar);  }
@Test public void insert() { Buffer buffer = new Buffer(new Prompt(": ")); List<int[]> outConsumer = new ArrayList<>(); buffer.print(outConsumer::add, 100); buffer.insert(outConsumer::add, 65, 100); assertEquals(1, buffer.length()); assertEquals(65, buffer.get(0)); buffer.insert(outConsumer::add, 66, 100); buffer.insert(outConsumer::add, 67, 100); assertEquals(66, buffer.get(1)); assertEquals(67, buffer.get(2)); assertEquals(": ", Parser.fromCodePoints( outConsumer.get(0))); assertArrayEquals(new int[] {65}, outConsumer.get(1)); assertArrayEquals(new int[] {66}, outConsumer.get(2)); assertArrayEquals(new int[] {67}, outConsumer.get(3)); assertEquals("ABC", buffer.asString()); buffer.reset(); outConsumer.clear(); buffer.print(outConsumer::add, 120); assertEquals(": ", Parser.fromCodePoints( outConsumer.get(0))); assertEquals(1, outConsumer.size()); buffer.insert(outConsumer::add, 'A', 100); buffer.insert(outConsumer::add, 'B', 100); buffer.insert(outConsumer::add, 'C', 100); assertEquals(66, buffer.get(1)); assertEquals(67, buffer.get(2)); outConsumer.clear(); buffer.insert(outConsumer::add, " foo", 100); assertEquals(" foo", Parser.fromCodePoints(outConsumer.get(0))); }