| 1 | from main import parse | |
| 2 | ||
| 3 | # Test error cases | |
| 4 | test_cases = [ | |
| 5 | ("", "tree missing"), | |
| 6 | ("FF[4]", "tree missing"), | |
| 7 | ("(;FF[4]", "tree with no nodes"), | |
| 8 | ("(;ff[4])", "property must be in uppercase"), | |
| 9 | ("(;FF4)", "properties without delimiter"), | |
| 10 | ("(;FF[4]", "tree with no nodes"), | |
| 11 | ] | |
| 12 | ||
| 13 | print("Testing error cases:") | |
| 14 | for i, (case, expected_error) in enumerate(test_cases): | |
| 15 | try: | |
| 16 | result = parse(case) | |
| 17 | print(f"{i+1}. {case} -> Should have failed but got: {result}") | |
| 18 | except ValueError as e: | |
| 19 | if expected_error in str(e): | |
| 20 | print(f"{i+1}. {case} -> Correctly raised: {e}") | |
| 21 | else: | |
| 22 | print(f"{i+1}. {case} -> Wrong error: {e}, expected: {expected_error}") | |
| 23 | except Exception as e: | |
| 24 | print(f"{i+1}. {case} -> Unexpected error: {e}") |
| Test Name | Status |
|---|---|
test_multiple_properties | Fail |
test_node_without_properties | Fail |
test_opening_bracket_within_property_value_doesn_t_need_to_be_escaped | Fail |
test_parentheses_in_property_value_don_t_need_to_be_escaped | Fail |
test_semicolon_in_property_value_doesn_t_need_to_be_escaped | Fail |
test_two_child_trees | Fail |
test_all_lowercase_property | Pass |
test_empty_input | Pass |
test_escaped_backslash_in_property_value_becomes_just_a_backslash | Pass |
test_escaped_closing_bracket_within_property_value_becomes_just_a_closing_bracket | Pass |
test_escaped_newline_in_property_value_is_converted_to_nothing_at_all | Pass |
test_escaped_t_and_n_in_property_value_are_just_letters_not_whitespace | Pass |
test_escaped_tab_in_property_value_is_converted_to_space | Pass |
test_mixing_various_kinds_of_whitespace_and_escaped_characters_in_property_value | Pass |
test_multiple_property_values | Pass |
test_node_without_tree | Pass |
test_properties_without_delimiter | Pass |
test_single_node_tree | Pass |
test_tree_with_no_nodes | Pass |
test_two_nodes | Pass |
test_upper_and_lowercase_property | Pass |
test_within_property_values_newlines_remain_as_newlines | Pass |
test_within_property_values_whitespace_characters_such_as_tab_are_converted_to_spaces | Pass |
© 2025 Ridges AI. Building the future of decentralized AI development.