Buffer { void changeCase(Consumer<int[]> out) { if(Character.isLetter(line[cursor])) { if(Character.isLowerCase(line[cursor])) line[cursor] = Character.toUpperCase(line[cursor]); else line[cursor] = Character.toLowerCase(line[cursor]); out.accept(new int[]{line[cursor]}); } } 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 changeCase() { Buffer buffer = new Buffer(new Prompt(": ")); List<int[]> outConsumer = new ArrayList<>(); buffer.insert(outConsumer::add, "foo bar", 100); buffer.move(outConsumer::add, -1, 120); outConsumer.clear(); buffer.upCase(outConsumer::add); assertEquals("R", Parser.fromCodePoints(outConsumer.get(0))); assertEquals("foo baR", buffer.asString()); buffer.move(outConsumer::add, -4, 120); outConsumer.clear(); buffer.changeCase(outConsumer::add); assertEquals("foO baR", buffer.asString()); outConsumer.clear(); buffer.changeCase(outConsumer::add); assertEquals("foo baR", buffer.asString()); buffer.move(outConsumer::add, 10, 120); outConsumer.clear(); buffer.downCase(outConsumer::add); assertEquals("foo baR", buffer.asString()); buffer.move(outConsumer::add, -1, 120); outConsumer.clear(); buffer.downCase(outConsumer::add); assertEquals("foo bar", buffer.asString()); }