Team Ai
Apppublic

cactus183/patchbench-dev

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
test_code.py37 linesDownload Raw Back to hard_03
1from solution import encode, decode2 3 4def test_encode_null():5    assert encode(None) == "null"6 7 8def test_encode_int():9    assert encode(42) == "42"10 11 12def test_encode_bool_true():13    assert encode(True) == "true"14 15 16def test_encode_string_simple():17    assert encode("hello") == '"hello"'18 19 20def test_encode_string_with_quote():21    # Internal quotes must be escaped with backslash22    assert encode('say "hi"') == '"say \\"hi\\""'23 24 25def test_decode_int():26    assert decode("42") == 4227 28 29def test_round_trip_nested_list():30    original = [1, [2, 3]]31    assert decode(encode(original)) == original32 33 34def test_round_trip_dict_with_list():35    original = {"a": [1, 2]}36    assert decode(encode(original)) == original37