CursesLikeAPI implements TerminalInterface { public void puts(String what) { this.mvputs(terminal.getCursorY(), terminal.getCursorX(), what); } CursesLikeAPI(TerminalInterface terminal); void addch(int what); @Override void clear(); int getCurBackground(); int getCurForeground(); @Override @Deprecated int[] getCursorLocation(); @Override Positionable getCursorPosition(); @Override int getCursorX(); @Override int getCursorY(); String gets(int length); @Override String getString(int y, int x, int length); void init(); boolean isSeparateCursor(); void move(int y, int x); void mvaddch(int y, int x, int what); int mvgetch(int y, int x); void mvoverlaych(int y, int x, int what); void mvputs(int y, int x, String str); void overlaych(int what); void puts(String what); void setCurBackground(int c); void setCurBackground(String c); void setCurForeground(int c); void setCurForeground(String c); @Deprecated void setSeparateCursor(boolean separateCursor); @Override void clear(TerminalCellLike empty); @Override void copyFrom(TerminalViewInterface oterm, int numRows, int numCols, int startY, int startX, int destY, int destX); @Override void disableEventNotice(BlackenEventType event); void doupdate(); @Override void doUpdate(); @Override void disableEventNotices(); @Override void enableEventNotice(BlackenEventType event); @Override @Deprecated void enableEventNotices(EnumSet<BlackenEventType> events); @Override TerminalCellLike get(int y, int x); @Override int getch(); @Override int getch(int millis); @Override boolean keyWaiting(); @Override Regionlike getBounds(); @Override TerminalCellLike getEmpty(); @Override Grid<TerminalCellLike> getGrid(); @Override int getHeight(); @Override EnumSet<BlackenModifier> getLockingStates(); @Override BlackenMouseEvent getmouse(); @Override ColorPalette getPalette(); @Override int getWidth(); @Override BlackenWindowEvent getwindow(); @Override @Deprecated int gridHeight(); @Override @Deprecated int gridWidth(); @Override void init(String name, int rows, int cols); @Override void init(String name, int rows, int cols, String... font); @Override void moveBlock(int numRows, int numCols, int origY, int origX,
            int newY, int newX); @Override void quit(); @Override void refresh(); @Override void resize(int rows, int cols); @Override void set(int y, int x, String sequence, Integer foreground, Integer background, EnumSet<TerminalStyle> style, EnumSet<CellWalls> walls); @Override void set(int y, int x, TerminalCellLike cell); @Override void set(int y, int x, String sequence, Integer foreground, Integer background); @Override void setCursorLocation(int y, int x); @Override @Deprecated void setCursorLocation(int[] pos); @Override void setCursorPosition(Positionable pos); @Override void setEmpty(TerminalCellLike empty); @Override void setFont(String font, boolean checkFont); @Override String setFont(String... font); @Override ColorPalette setPalette(ColorPalette palette); @Override ColorPalette coerceToPalette(ColorPalette palette, Integer white, Integer black); @Override ColorPalette coerceToPalette(ColorPalette palette, String white, String black); @Override @Deprecated ColorPalette setPalette(ColorPalette palette, int white, int black); @Override TerminalCellLike assign(int y, int x, TerminalCellLike cell); @Override boolean setFullScreen(boolean state); @Override boolean getFullScreen(); @Override void inhibitFullScreen(boolean state); @Override TerminalInterface getBackingTerminal(); @Override void init(String name, int rows, int cols, TerminalScreenSize size, String... font); @Override void init(String name, int rows, int cols, TerminalScreenSize size); @Override boolean isRunning(); @Override void setSize(TerminalScreenSize size); @Override @Deprecated TerminalInterface getBackingTerminalInterface(); @Override TerminalViewInterface getBackingTerminalView(); @Override void setBounds(Regionlike bounds); @Override void setBounds(int rows, int cols, int y1, int x1); @Override void refresh(int y, int x); @Override void setEventNotices(EnumSet<BlackenEventType> events); @Override EnumSet<BlackenEventType> getEventNotices(); @Override Positionable putString(int y, int x, String string); @Override void applyTemplate(int y, int x, TerminalCellTemplate template, int length); @Override Positionable putString(Positionable pos, String string); @Override BlackenImageLoader getImageLoader(); @Override int getX(); @Override int getY(); @Override BlackenConfig overrideConfig(String gameName);  }
@Test @Covers({"public void mvputs(int,int,String)", "public void puts(String)"}) public void puts() { assertEquals(0, terminal.getCursorY()); assertEquals(0, terminal.getCursorX()); terminal.addch('+'); terminal.mvaddch(0, 3, '_'); assertEquals(0, terminal.getCursorY()); assertEquals(4, terminal.getCursorX()); assertEquals("baseline failure", "+", terminal.get(0, 0).getSequence()); assertEquals("overwrite test failure", "_", terminal.get(0, 3).getSequence()); terminal.puts("\r...\r"); assertEquals("CR test failure.", ".", terminal.get(0, 0).getSequence()); assertEquals("CR test overwrite failure.", "_", terminal.get(0, 3).getSequence()); assertEquals(0, terminal.getCursorY()); assertEquals(0, terminal.getCursorX()); terminal.puts("ABC"); assertEquals(0, terminal.getCursorY()); assertEquals(3, terminal.getCursorX()); assertEquals("Simple puts failure","A", terminal.get(0, 0).getSequence()); assertEquals("Simple puts failure","B", terminal.get(0, 1).getSequence()); assertEquals("Simple puts failure","C", terminal.get(0, 2).getSequence()); assertEquals("Simple puts overwrite failure","_", terminal.get(0, 3).getSequence()); StringBuilder buf = new StringBuilder(); String a1; buf.append('a'); buf.appendCodePoint(BlackenCodePoints.CODEPOINT_COMBINING_DIAERESIS); a1 = buf.toString(); terminal.mvputs(0, 0, a1); assertEquals(a1, terminal.get(0, 0).getSequence()); assertEquals("B", terminal.get(0, 1).getSequence()); assertEquals("C", terminal.get(0, 2).getSequence()); assertEquals(0, terminal.getCursorY()); assertEquals(1, terminal.getCursorX()); buf.setLength(0); assertEquals("", buf.toString()); buf.append('b'); buf.appendCodePoint(BlackenCodePoints.CODEPOINT_COMBINING_RING_ABOVE); buf.appendCodePoint(BlackenCodePoints.CODEPOINT_COMBINING_RING_BELOW); String b1 = buf.toString(); terminal.mvputs(0, 1, b1); assertEquals(b1, terminal.get(0, 1).getSequence()); assertEquals("C", terminal.get(0, 2).getSequence()); assertEquals(0, terminal.getCursorY()); assertEquals(2, terminal.getCursorX()); buf.setLength(0); buf.append('c'); buf.appendCodePoint(BlackenCodePoints.CODEPOINT_COMBINING_CEDILLA); buf.appendCodePoint(BlackenCodePoints.CODEPOINT_COMBINING_INVERTED_BREVE); buf.appendCodePoint(BlackenCodePoints.CODEPOINT_COMBINING_CIRCUMFLEX_ACCENT); buf.appendCodePoint(BlackenCodePoints.CODEPOINT_COMBINING_BREVE); String c1 = buf.toString(); terminal.mvputs(0, 2, c1); assertEquals(c1, terminal.get(0, 2).getSequence()); assertEquals("_", terminal.get(0, 3).getSequence()); assertEquals(0, terminal.getCursorY()); assertEquals(3, terminal.getCursorX()); terminal.mvaddch(1, 3, '_'); assertEquals(1, terminal.getCursorY()); assertEquals(4, terminal.getCursorX()); assertEquals("_", terminal.get(0, 3).getSequence()); buf.setLength(0); buf.append("\r"); buf.append(a1); buf.append(b1); buf.append(c1); buf.append("\n"); terminal.puts(buf.toString()); assertEquals(2, terminal.getCursorY()); assertEquals(0, terminal.getCursorX()); assertEquals(a1, terminal.get(1, 0).getSequence()); assertEquals(b1, terminal.get(1, 1).getSequence()); assertEquals(c1, terminal.get(1, 2).getSequence()); assertEquals("_", terminal.get(1, 3).getSequence()); }