Skip to content

Commit

Permalink
Widen tests to cover more possible buffer overflows
Browse files Browse the repository at this point in the history
If the default output format changes in the future (e.g. `separators` as in the standard library), these tests would otherwise become irrelevant.
  • Loading branch information
JustAnotherArchivist authored and bwoodsend committed Apr 5, 2022
1 parent f4d2c87 commit 3c095f1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,12 +948,15 @@ def default(value):
ujson.dumps(unjsonable_obj, default=default)


def test_dump_huge_indent():
ujson.encode({"a": True}, indent=65539)
@pytest.mark.parametrize("indent", list(range(65537, 65542)))
def test_dump_huge_indent(indent):
ujson.encode({"a": True}, indent=indent)


def test_dump_long_string():
ujson.dumps(["aaaa", "\x00" * 10921])
@pytest.mark.parametrize("first_length", list(range(2, 7)))
@pytest.mark.parametrize("second_length", list(range(10919, 10924)))
def test_dump_long_string(first_length, second_length):
ujson.dumps(["a" * first_length, "\x00" * second_length])


def test_dump_indented_nested_list():
Expand Down

0 comments on commit 3c095f1

Please sign in to comment.