### Question:
InorderWithConstantSpace { public static List<TreeNode> solve(TreeNode root) { return null; }  static List<TreeNode> solve(TreeNode root);  }### Answer:
@Test public void basicTest() { TreeNode root = new TreeNode(1); root.left = new TreeNode(-2); root.right = new TreeNode(-3); List<TreeNode> res = InorderWithConstantSpace.solve(root); Assert.assertEquals(3, res.size()); Assert.assertEquals(root.left, res.get(0)); Assert.assertEquals(root, res.get(1)); Assert.assertEquals(root.right, res.get(2)); }
@Test public void basicTest2() { TreeNode root = new TreeNode(1); root.left = new TreeNode(-2); root.left.right = new TreeNode(-3); List<TreeNode> res = InorderWithConstantSpace.solve(root); Assert.assertEquals(3, res.size()); Assert.assertEquals(root.left, res.get(0)); Assert.assertEquals(root.left.right, res.get(1)); Assert.assertEquals(root, res.get(2)); }
@Test public void basicTest3() { TreeNode root = new TreeNode(1); root.left = new TreeNode(-2); root.left.left = new TreeNode(-3); List<TreeNode> res = InorderWithConstantSpace.solve(root); Assert.assertEquals(3, res.size()); Assert.assertEquals(root.left.left, res.get(0)); Assert.assertEquals(root.left, res.get(1)); Assert.assertEquals(root, res.get(2)); }
@Test public void randomTest() { int N = 100000; Random r = new Random(); for (int i = 10; i < N; i += r.nextInt(i)) { TreeNode root = TreeNode.buildBT(i); List<TreeNode> res = InorderWithConstantSpace.solve(root); List<TreeNode> expect = expect(root); Assert.assertArrayEquals(expect.toArray(new TreeNode[0]), res.toArray(new TreeNode[0])); } }