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

Method acceptFile

test/testpath.cpp:75–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 }
74
75 void acceptFile() const {
76 ASSERT(Path::acceptFile("index.c"));
77 ASSERT(Path::acceptFile("index.cpp"));
78 ASSERT(Path::acceptFile("index.invalid.cpp"));
79 ASSERT(Path::acceptFile("index.invalid.Cpp"));
80 ASSERT(Path::acceptFile("index.invalid.C"));
81 ASSERT(Path::acceptFile("index.invalid.C++"));
82 ASSERT(Path::acceptFile("index.")==false);
83 ASSERT(Path::acceptFile("index")==false);
84 ASSERT(Path::acceptFile("")==false);
85 ASSERT(Path::acceptFile("C")==false);
86 {
87 Standards::Language lang;
88 ASSERT(Path::acceptFile("index.c", &lang));
89 ASSERT_EQUALS_ENUM(Standards::Language::C, lang);
90 }
91 {
92 Standards::Language lang;
93 ASSERT(Path::acceptFile("index.cpp", &lang));
94 ASSERT_EQUALS_ENUM(Standards::Language::CPP, lang);
95 }
96
97 // don't accept any headers
98 ASSERT_EQUALS(false, Path::acceptFile("index.h"));
99 ASSERT_EQUALS(false, Path::acceptFile("index.hpp"));
100
101 const std::set<std::string> extra = { ".extra", ".header" };
102 ASSERT(Path::acceptFile("index.c", extra));
103 ASSERT(Path::acceptFile("index.cpp", extra));
104 ASSERT(Path::acceptFile("index.extra", extra));
105 ASSERT(Path::acceptFile("index.header", extra));
106 ASSERT(Path::acceptFile("index.h", extra)==false);
107 ASSERT(Path::acceptFile("index.hpp", extra)==false);
108 {
109 Standards::Language lang;
110 ASSERT(Path::acceptFile("index.c", extra, &lang));
111 ASSERT_EQUALS_ENUM(Standards::Language::C, lang);
112 }
113 {
114 Standards::Language lang;
115 ASSERT(Path::acceptFile("index.cpp", extra, &lang));
116 ASSERT_EQUALS_ENUM(Standards::Language::CPP, lang);
117 }
118 {
119 Standards::Language lang;
120 ASSERT(Path::acceptFile("index.extra", extra, &lang));
121 ASSERT_EQUALS_ENUM(Standards::Language::None, lang);
122 }
123 }
124
125 void getCurrentPath() const {
126 ASSERT_EQUALS(true, Path::isAbsolute(Path::getCurrentPath()));

Callers

nothing calls this directly

Calls 1

acceptFileFunction · 0.85

Tested by

no test coverage detected