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)
|
||||
|
||||
def _build_cases_array(self, name, entries):
|
||||
lines = [
|
||||
f" struct {name}Case {{ const char *s; WeaselJsonStatus expected; long long v; }};"
|
||||
]
|
||||
lines = [f" struct {name}Case {{ const char *s; WeaselJsonStatus expected; long long v; }};"]
|
||||
lines.append(f" {name}Case {name}_cases[] = {{")
|
||||
for s, exp, v in entries:
|
||||
val = f"{v}LL" if isinstance(v, int) else v
|
||||
@@ -395,11 +393,7 @@ class SchemagenIntegerBoundaryTest(unittest.TestCase):
|
||||
('{"age":1e3}', "WeaselJson_OK", 1000),
|
||||
('{"age":2.0}', "WeaselJson_OK", 2),
|
||||
('{"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)
|
||||
harness = textwrap.dedent(
|
||||
|
||||
@@ -1001,15 +1001,9 @@ private:
|
||||
mag *= 10;
|
||||
}}
|
||||
if (mag > limit) return false;
|
||||
if (neg) {{
|
||||
if (mag == kMaxNeg) {{
|
||||
out = INT64_MIN;
|
||||
}} else {{
|
||||
out = -static_cast<int64_t>(mag);
|
||||
}}
|
||||
}} else {{
|
||||
out = static_cast<int64_t>(mag);
|
||||
}}
|
||||
__int128 signedMag = static_cast<__int128>(mag);
|
||||
if (neg) signedMag = -signedMag;
|
||||
out = static_cast<int64_t>(signedMag);
|
||||
return true;
|
||||
}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user