Skip to content

Commit 2dfbdaa

Browse files
committed
Add regression tests for unsigned constants
Large, unsigned, constants result in an Overflow error. I discovered this while running CBI on a new code base that tries to check the value of ULONG_MAX. Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent 180cef8 commit 2dfbdaa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/literals/test_literals.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import unittest
66
from pathlib import Path
77

8+
import numpy as np
9+
810
from codebasin import CodeBase, finder, preprocessor
911

1012

@@ -60,6 +62,11 @@ def test_strings(self):
6062
)
6163
self.assertEqual(tokens[0].token, expected.token)
6264

65+
def test_long_constants(self):
66+
tokens = preprocessor.Lexer("0xFFFFFFFFFFFFFFFFULL").tokenize()
67+
term = preprocessor.ExpressionEvaluator(tokens).term()
68+
self.assertEqual(term, np.uint64(int("0xFFFFFFFFFFFFFFFF", 16)))
69+
6370

6471
if __name__ == "__main__":
6572
unittest.main()

0 commit comments

Comments
 (0)