Test round-trip of complex structure.
()
| 100 | |
| 101 | |
| 102 | def test_roundtrip_complex_structure(): |
| 103 | """Test round-trip of complex structure.""" |
| 104 | original = { |
| 105 | 'project': 'TOON', |
| 106 | 'version': '1.0.0', |
| 107 | 'description': 'A token-efficient format', |
| 108 | 'features': ['compact', 'readable', 'structured'], |
| 109 | 'users': [ |
| 110 | {'id': 1, 'name': 'Alice', 'active': True}, |
| 111 | {'id': 2, 'name': 'Bob', 'active': False} |
| 112 | ], |
| 113 | 'metadata': { |
| 114 | 'created': '2024-01-01', |
| 115 | 'author': 'TOON Contributors', |
| 116 | 'stats': { |
| 117 | 'files': 10, |
| 118 | 'lines': 1000 |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | toon = encode(original) |
| 124 | result = decode(toon) |
| 125 | |
| 126 | assert result == original |
| 127 | |
| 128 | |
| 129 | def test_roundtrip_with_delimiters(): |