diff --git a/lizard_languages/code_reader.py b/lizard_languages/code_reader.py index 9e12658..e8d7d98 100644 --- a/lizard_languages/code_reader.py +++ b/lizard_languages/code_reader.py @@ -127,6 +127,8 @@ def _generate_tokens(source, add, flags=re.NOFLAG): r"\/\*.*?\*\/" + add + r"|(?:\d+\')+\d+" + + r"|0x(?:[0-9A-Fa-f]+\')+[0-9A-Fa-f]+" + + r"|0b(?:[01]+\')+[01]+" + r"|\w+" + r"|\"(?:\\.|[^\"\\])*\"" + r"|\'(?:\\.|[^\'\\])*?\'" + diff --git a/test/test_languages/testCAndCPP.py b/test/test_languages/testCAndCPP.py index 17646ce..b04b901 100644 --- a/test/test_languages/testCAndCPP.py +++ b/test/test_languages/testCAndCPP.py @@ -100,6 +100,20 @@ def test_number_with_thousands_separator_since_cpp14(self): self.assertEqual(1, len(result)) self.assertEqual(2, result[0].cyclomatic_complexity) + def test_hex_number_with_thousands_separator_since_cpp14(self): + result = get_cpp_function_list("""int fun(){ + int a= 0x12ab'34cd; if(b) c; return 0xEF56'7890'1A2B; + }""") + self.assertEqual(1, len(result)) + self.assertEqual(2, result[0].cyclomatic_complexity) + + def test_bin_number_with_thousands_separator_since_cpp14(self): + result = get_cpp_function_list("""int fun(){ + int a= 0b0101'1100; if(b) c; return 0b1111'0000'1100'1110; + }""") + self.assertEqual(1, len(result)) + self.assertEqual(2, result[0].cyclomatic_complexity) + def test_function_with_no_param_omitted(self): result = get_cpp_function_list("int fun(){}") self.assertEqual(0, result[0].parameter_count)