leetcode-helper icon indicating copy to clipboard operation
leetcode-helper copied to clipboard

How to test with leetcode data structure?

Open jinniw43805 opened this issue 6 years ago • 1 comments

Since I've created an solution1 class to implement solution interface which takes TreeNode class param, but when I went to Tester.java part tried to write test case with TreeNode, how do I declare the TreeNode structure

For example, if I want to give a binary tree [3,9,20,null,null,15,7] as input () /** Initialize test cases */ @Parameters public static Collection<Object[]> testcases() { return Arrays.asList(new Object[][]{ {[3,9,20,null,null,15,7], 3} // test case 1 (init parameters below: {para1, para2, expected}) }); }

This shows error: illegal start of expression exception

How do you guys deal with leetcode structure in Tester.java

jinniw43805 avatar Jun 03 '19 06:06 jinniw43805

Just look TreeNode unit test part in source file https://github.com/helloShen/leetcode-helper/blob/master/src/test/java/com/ciaoshen/leetcode/util/TreeNodeTest.java Seems you establish the tree structure in setUpBeforeClass() function, do we have to use the same idea to deal this one?

jinniw43805 avatar Jun 03 '19 06:06 jinniw43805