/*******************************************************************************************/ /*******************************************************************************************/ private void CheckNode <T>(Node node, List <T> valuesToCheck) { if (valuesToCheck is null) { Assert.IsNull(node); return; } if (node.IsLeft()) { CheckNode(node.Left, valuesToCheck); } if (node.IsRight()) { CheckNode(node.Right, valuesToCheck); } if (typeof(T) == typeof(int)) { Assert.AreEqual(node.Key, valuesToCheck[0]); } else { Assert.AreEqual(node.Color, valuesToCheck[0]); } valuesToCheck.RemoveAt(0); }
/*******************************************************************************************/ /*******************************************************************************************/ private void CheckNode(Node node, Stack <NodePosition> expectedPositions) { if (node.IsLeft()) { CheckNode(node.Left, expectedPositions); } if (node.IsRight()) { CheckNode(node.Right, expectedPositions); } NodePosition nodePosition = expectedPositions.Pop(); Assert.AreEqual(node.Key, nodePosition.key); Assert.AreEqual(node.PosHor, nodePosition.posHor); Assert.AreEqual(node.PosVer, nodePosition.posVer); }