Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9dfb3becc |
@@ -324,9 +324,7 @@ class SchemagenIntegerBoundaryTest(unittest.TestCase):
|
|||||||
self.assertEqual(run.returncode, 0, msg=run.stdout + run.stderr)
|
self.assertEqual(run.returncode, 0, msg=run.stdout + run.stderr)
|
||||||
|
|
||||||
def _build_cases_array(self, name, entries):
|
def _build_cases_array(self, name, entries):
|
||||||
lines = [
|
lines = [f" struct {name}Case {{ const char *s; WeaselJsonStatus expected; long long v; }};"]
|
||||||
f" struct {name}Case {{ const char *s; WeaselJsonStatus expected; long long v; }};"
|
|
||||||
]
|
|
||||||
lines.append(f" {name}Case {name}_cases[] = {{")
|
lines.append(f" {name}Case {name}_cases[] = {{")
|
||||||
for s, exp, v in entries:
|
for s, exp, v in entries:
|
||||||
val = f"{v}LL" if isinstance(v, int) else v
|
val = f"{v}LL" if isinstance(v, int) else v
|
||||||
@@ -395,11 +393,7 @@ class SchemagenIntegerBoundaryTest(unittest.TestCase):
|
|||||||
('{"age":1e3}', "WeaselJson_OK", 1000),
|
('{"age":1e3}', "WeaselJson_OK", 1000),
|
||||||
('{"age":2.0}', "WeaselJson_OK", 2),
|
('{"age":2.0}', "WeaselJson_OK", 2),
|
||||||
('{"age":0.001}', "WeaselJson_REJECT", 0),
|
('{"age":0.001}', "WeaselJson_REJECT", 0),
|
||||||
(
|
('{"age":-9223372036854775808.0}', "WeaselJson_OK", "-9223372036854775807LL - 1"),
|
||||||
'{"age":-9223372036854775808.0}',
|
|
||||||
"WeaselJson_OK",
|
|
||||||
"-9223372036854775807LL - 1",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
cases_src = self._build_cases_array("object", cases)
|
cases_src = self._build_cases_array("object", cases)
|
||||||
harness = textwrap.dedent(
|
harness = textwrap.dedent(
|
||||||
|
|||||||
@@ -1001,15 +1001,9 @@ private:
|
|||||||
mag *= 10;
|
mag *= 10;
|
||||||
}}
|
}}
|
||||||
if (mag > limit) return false;
|
if (mag > limit) return false;
|
||||||
if (neg) {{
|
__int128 signedMag = static_cast<__int128>(mag);
|
||||||
if (mag == kMaxNeg) {{
|
if (neg) signedMag = -signedMag;
|
||||||
out = INT64_MIN;
|
out = static_cast<int64_t>(signedMag);
|
||||||
}} else {{
|
|
||||||
out = -static_cast<int64_t>(mag);
|
|
||||||
}}
|
|
||||||
}} else {{
|
|
||||||
out = static_cast<int64_t>(mag);
|
|
||||||
}}
|
|
||||||
return true;
|
return true;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user