History { public abstract int[] search(int[] search);  boolean isEnabled(); void enable(); void disable(); abstract void push(int[] entry); abstract int[] find(int[] search); abstract int[] get(int index); abstract int size(); abstract void setSearchDirection(SearchDirection direction); abstract SearchDirection getSearchDirection(); abstract int[] getNextFetch(); abstract int[] getPreviousFetch(); abstract int[] search(int[] search); abstract void setCurrent(int[] line); abstract int[] getCurrent(); abstract List<int[]> getAll(); abstract void clear(); abstract void stop();  }
@Test public void testSearch() { History history = new InMemoryHistory(20); history.push(Parser.toCodePoints("foo1")); history.push(Parser.toCodePoints("foo2")); history.push(Parser.toCodePoints("foo3")); history.setSearchDirection(SearchDirection.REVERSE); assertArrayEquals(Parser.toCodePoints("foo3"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo2"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo1"),history.search(Parser.toCodePoints("foo")) ); history.setSearchDirection(SearchDirection.FORWARD); assertArrayEquals(Parser.toCodePoints("foo1"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo2"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo3"),history.search(Parser.toCodePoints("foo")) ); history.setSearchDirection(SearchDirection.REVERSE); assertArrayEquals(Parser.toCodePoints("foo3"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo2"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo1"),history.search(Parser.toCodePoints("foo")) ); history.setSearchDirection(SearchDirection.REVERSE); assertArrayEquals(Parser.toCodePoints("foo3"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo2"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo1"),history.search(Parser.toCodePoints("foo")) ); assertArrayEquals(Parser.toCodePoints("foo3"),history.search(Parser.toCodePoints("foo")) ); }