From 6d93b150b894c73656c33c56d049e45f70f8e3db Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 18 Mar 2025 13:27:02 +1100 Subject: [PATCH] tests/extmod/json_loads_int_64.py: Add test cases for LONGINT parse. These tests cover the use of mp_obj_new_int_from_str_len when mp_parse_num_integer overflows the SMALLINT limit, and also the case where the value may not be null terminated. Placed in a separate test file so that extmod/json test doesn't rely on bigint support. Signed-off-by: Yoctopuce dev Signed-off-by: Angus Gratton --- tests/extmod/json_loads_int_64.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/extmod/json_loads_int_64.py diff --git a/tests/extmod/json_loads_int_64.py b/tests/extmod/json_loads_int_64.py new file mode 100644 index 0000000000..193a3c28d8 --- /dev/null +++ b/tests/extmod/json_loads_int_64.py @@ -0,0 +1,16 @@ +# Parse 64-bit integers from JSON payloads. +# +# This also exercises parsing integers from strings +# where the value may not be null terminated (last line) +try: + import json +except ImportError: + print("SKIP") + raise SystemExit + + +print(json.loads("9111222333444555666")) +print(json.loads("-9111222333444555666")) +print(json.loads("9111222333444555666")) +print(json.loads("-9111222333444555666")) +print(json.loads("[\"9111222333444555666777\",9111222333444555666]"))