@Test public void testSort() { Stack<Integer> s1 = new Stack<>(); s1.push(3); s1.push(1); s1.push(5); s1.push(2); s1.push(8); s1.push(2); assertEquals("|315282", s1.toString()); Stack.sort(s1); assertEquals("|853221", s1.toString()); }
@Test public void testTowersOfHanoi() { Stack<Integer> src = new Stack<>(); Stack<Integer> temp = new Stack<>(); Stack<Integer> dest = new Stack<>(); for (int i = 5; i > 0; i--) { src.push(i); } System.out.println(src.toString()); System.out.println(temp.toString()); System.out.println(dest.toString()); System.out.println(); Stack.towersOfHanoi(5, src, temp, dest); System.out.println(src.toString()); System.out.println(temp.toString()); System.out.println(dest.toString()); System.out.println(); assertEquals("|54321", dest.toString()); }