RedBlackTree { protected Node rotateLeft(Node h) { assert(h != null); Node x = h.right; h.right = x.left; x.left = h; x.color = h.color; h.color = RedBlackTree.Color.RED; x.N = h.N; h.N = 1 + size(h.left) + size(h.right); return x; }    }
@Test public void rotateLeft1() { RedBlackTree<String, Integer>.Node nodeE = tester.new Node("E", 1, 6, RedBlackTree.Color.BLACK); RedBlackTree<String, Integer>.Node nodeC = tester.new Node("C", 1, 2, RedBlackTree.Color.BLACK); RedBlackTree<String, Integer>.Node nodeA = tester.new Node("A", 1, 1, RedBlackTree.Color.RED); RedBlackTree<String, Integer>.Node nodeR = tester.new Node("R", 1, 3, RedBlackTree.Color.RED); RedBlackTree<String, Integer>.Node nodeH = tester.new Node("H", 1, 1, RedBlackTree.Color.BLACK); RedBlackTree<String, Integer>.Node nodeS = tester.new Node("S", 1, 1, RedBlackTree.Color.BLACK); nodeE.left = nodeC; nodeC.left = nodeA; nodeE.right = nodeR; nodeR.left = nodeH; nodeR.right = nodeS; RedBlackTree<String, Integer>.Node nodeERotated = tester.rotateLeft(nodeE); assertEquals(nodeERotated, nodeR); nodeR = nodeERotated; assertEquals("R", nodeR.key); assertEquals(RedBlackTree.Color.BLACK, nodeR.color); assertEquals(6, nodeR.N); assertEquals(nodeS, nodeR.right); assertEquals(nodeE, nodeR.left); assertEquals("E", nodeE.key); assertEquals(RedBlackTree.Color.RED, nodeE.color); assertEquals(4, nodeE.N); assertEquals(nodeH, nodeE.right); assertEquals(nodeC, nodeE.left); assertEquals("H", nodeH.key); assertEquals(RedBlackTree.Color.BLACK, nodeH.color); assertEquals(1, nodeH.N); assertEquals(null, nodeH.left); assertEquals(null, nodeH.right); assertEquals("C", nodeC.key); assertEquals(RedBlackTree.Color.BLACK, nodeC.color); assertEquals(2, nodeC.N); assertEquals(nodeA, nodeC.left); assertEquals(null, nodeC.right); assertEquals("A", nodeA.key); assertEquals(RedBlackTree.Color.RED, nodeA.color); assertEquals(1, nodeA.N); assertEquals(null, nodeA.left); assertEquals(null, nodeA.right); }