MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / test_addon_namingng

Function test_addon_namingng

test/cli/other_test.py:508–683  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

506
507
508def test_addon_namingng(tmpdir):
509 addon_file = os.path.join(tmpdir, 'namingng.json')
510 addon_config_file = os.path.join(tmpdir, 'namingng.config.json')
511 with open(addon_file, 'wt') as f:
512 f.write("""
513{
514 "script": "addons/namingng.py",
515 "args": [
516 "--configfile=%s"
517 ]
518}
519 """%(addon_config_file).replace('\\','\\\\'))
520
521 with open(addon_config_file, 'wt') as f:
522 f.write("""
523{
524 "RE_FILE": [
525 "[^/]*[a-z][a-z0-9_]*[a-z0-9]\\.c\\Z"
526 ],
527 "RE_CLASS_NAME": ["[a-z][a-z0-9_]*[a-z0-9]\\Z"],
528 "RE_NAMESPACE": ["[a-z][a-z0-9_]*[a-z0-9]\\Z"],
529 "RE_VARNAME": ["[a-z][a-z0-9_]*[a-z0-9]\\Z"],
530 "RE_PUBLIC_MEMBER_VARIABLE": ["[a-z][a-z0-9_]*[a-z0-9]\\Z"],
531 "RE_PRIVATE_MEMBER_VARIABLE": {
532 ".*_tmp\\Z":[true,"illegal suffix _tmp"],
533 "priv_.*\\Z":[false,"required prefix priv_ missing"]
534 },
535 "RE_GLOBAL_VARNAME": ["[a-z][a-z0-9_]*[a-z0-9]\\Z"],
536 "RE_FUNCTIONNAME": ["[a-z][a-z0-9_]*[a-z0-9]\\Z"],
537 "include_guard": {
538 "input": "basename",
539 "prefix": "_",
540 "suffix": "",
541 "case": "upper",
542 "max_linenr": 5,
543 "RE_HEADERFILE": ".*\\.h\\Z",
544 "required": true
545 },
546 "var_prefixes": {"uint32_t": "ui32"},
547 "function_prefixes": {"uint16_t": "ui16",
548 "uint32_t": "ui32"},
549 "skip_one_char_variables": false
550}
551 """.replace('\\','\\\\'))
552
553 test_unguarded_include_file_basename = 'test_unguarded.h'
554 test_unguarded_include_file = os.path.join(tmpdir, test_unguarded_include_file_basename)
555 with open(test_unguarded_include_file, 'wt') as f:
556 f.write("""
557void InvalidFunctionUnguarded();
558""")
559
560 test_include_file_basename = '_test.h'
561 test_include_file = os.path.join(tmpdir, test_include_file_basename)
562 with open(test_include_file, 'wt') as f:
563 f.write("""
564#ifndef TEST_H
565#define TEST_H

Callers

nothing calls this directly

Calls 6

cppcheckFunction · 0.90
__remove_verbose_logFunction · 0.85
formatMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected