@@ -50,6 +50,12 @@ Required fields for `leetcode_py/cli/resources/leetcode/json/problems/{problem_n
5050- ` playground_assertion ` : Use single quotes for string literals
5151- Double quotes in JSON + cookiecutter + Jupyter notebook = triple escaping issues
5252
53+ ** Test Cases Format:**
54+
55+ - ` test_cases ` : Use structured format with ` {"list": ["..."]} ` instead of string arrays
56+ - Each test case should be a string representation of the tuple/parameters
57+ - Example: ` {"list": ["('input1', 'input2', expected)", "('input3', 'input4', expected)"]} `
58+
5359** IMPORTANT: Create actual JSON files, not JSON5**
5460
5561The template below uses JSON5 format with comments for documentation purposes only. When creating the actual ` .json ` file, you must:
@@ -183,9 +189,30 @@ The template below uses JSON5 format with comments for documentation purposes on
183189 parametrize: " s, t, expected" , // pytest parametrize parameters
184190 // For tree: "root_list, expected_list"
185191 // For design: "operations, inputs, expected"
186- test_cases: " [('anagram', 'nagaram', True), ('rat', 'car', False), ('listen', 'silent', True), ('hello', 'bello', False), ('', '', True), ('a', 'a', True), ('a', 'b', False), ('ab', 'ba', True), ('abc', 'bca', True), ('abc', 'def', False), ('aab', 'abb', False), ('aabbcc', 'abcabc', True), ('abcd', 'abcde', False), ('race', 'care', True), ('elbow', 'below', True), ('study', 'dusty', True), ('night', 'thing', True), ('stressed', 'desserts', True)]" ,
187- // For tree: "[([4, 2, 7, 1, 3, 6, 9], [4, 7, 2, 9, 6, 3, 1]), ([2, 1, 3], [2, 3, 1]), ([], [])]"
188- // For design: "[(['LRUCache', 'put', 'get'], [[2], [1, 1], [1]], [None, None, 1])]"
192+ test_cases: {
193+ list: [
194+ " ('anagram', 'nagaram', True)" ,
195+ " ('rat', 'car', False)" ,
196+ " ('listen', 'silent', True)" ,
197+ " ('hello', 'bello', False)" ,
198+ " ('', '', True)" ,
199+ " ('a', 'a', True)" ,
200+ " ('a', 'b', False)" ,
201+ " ('ab', 'ba', True)" ,
202+ " ('abc', 'bca', True)" ,
203+ " ('abc', 'def', False)" ,
204+ " ('aab', 'abb', False)" ,
205+ " ('aabbcc', 'abcabc', True)" ,
206+ " ('abcd', 'abcde', False)" ,
207+ " ('race', 'care', True)" ,
208+ " ('elbow', 'below', True)" ,
209+ " ('study', 'dusty', True)" ,
210+ " ('night', 'thing', True)" ,
211+ " ('stressed', 'desserts', True)" ,
212+ ],
213+ },
214+ // For tree: {"list": ["([4, 2, 7, 1, 3, 6, 9], [4, 7, 2, 9, 6, 3, 1])", "([2, 1, 3], [2, 3, 1])", "([], [])"]}
215+ // For design: {"list": ["(['LRUCache', 'put', 'get'], [[2], [1, 1], [1]], [None, None, 1])"]}
189216 body: " result = run_is_anagram(Solution, s, t)\n assert_is_anagram(result, expected)" ,
190217 // For tree: " result = run_invert_tree(Solution, root_list)\n assert_invert_tree(result, expected_list)"
191218 // For design: " result, _ = run_lru_cache(LRUCache, operations, inputs)\n assert_lru_cache(result, expected)"
@@ -218,29 +245,29 @@ The template below uses JSON5 format with comments for documentation purposes on
218245 // - solution_class_name: "Solution"
219246 // - solution_imports: ""
220247 // - Simple method signatures: "(self, s: str, t: str) -> bool"
221- // - Basic test cases: string/number parameters
248+ // - Basic test cases: structured format with {"list": ["..."]}
222249 // - Playground: single quotes for strings
223250 //
224251 // TREE PROBLEMS (invert_binary_tree):
225252 // - solution_class_name: "Solution"
226253 // - solution_imports: "from leetcode_py import TreeNode"
227254 // - Tree method signatures: "(self, root: TreeNode[int] | None) -> TreeNode[int] | None"
228255 // - Helper functions use TreeNode.from_list()
229- // - Test cases: list representations of trees
256+ // - Test cases: structured format with list representations of trees
230257 // - Playground: TreeNode imports and list conversions
231258 //
232259 // LINKED LIST PROBLEMS (merge_two_sorted_lists):
233260 // - solution_class_name: "Solution"
234261 // - solution_imports: "from leetcode_py import ListNode"
235262 // - List method signatures: "(self, list1: ListNode[int] | None, list2: ListNode[int] | None) -> ListNode[int] | None"
236263 // - Helper functions use ListNode.from_list()
237- // - Test cases: list representations of linked lists
264+ // - Test cases: structured format with list representations of linked lists
238265 // - Playground: ListNode imports and list conversions
239266 //
240267 // DESIGN PROBLEMS (lru_cache):
241268 // - solution_class_name: "LRUCache" (custom class name)
242269 // - Multiple methods including __init__
243- // - Operations-based testing: operations, inputs, expected arrays
270+ // - Operations-based testing: structured format with operations, inputs, expected arrays
244271 // - Complex test body with operation loops
245272 // - Helper functions return (results, instance) for debugging
246273 // - Playground: print results, return instance
@@ -250,7 +277,7 @@ The template below uses JSON5 format with comments for documentation purposes on
250277 // - solution_class_name: "Trie(DictTree[str])" (with inheritance)
251278 // - solution_imports: "from leetcode_py.data_structures import DictTree, RecursiveDict"
252279 // - Custom class with inheritance from DictTree
253- // - Operations-based testing like design problems
280+ // - Operations-based testing with structured format like design problems
254281 // - Helper functions return (results, instance) for debugging
255282 //
256283 // MULTIPLE SOLUTIONS (invert_binary_tree, lru_cache):
0 commit comments