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

Method check

test/testsingleexecutor.cpp:69–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 };
68
69 void check(int files, int result, const std::string &data, const CheckOptions& opt = make_default_obj{}) {
70 std::list<FileSettings> fileSettings;
71
72 std::list<FileWithDetails> filelist;
73 if (opt.filesList.empty()) {
74 for (int i = 1; i <= files; ++i) {
75 std::string f_s = fprefix() + "_" + zpad3(i) + ".c";
76 filelist.emplace_back(f_s, Standards::Language::C, data.size());
77 if (useFS) {
78 fileSettings.emplace_back(std::move(f_s), Standards::Language::C, data.size());
79 }
80 }
81 }
82 else {
83 for (const auto& f : opt.filesList)
84 {
85 filelist.emplace_back(f, Standards::Language::C, data.size());
86 if (useFS) {
87 fileSettings.emplace_back(f, Standards::Language::C, data.size());
88 }
89 }
90 }
91
92 /*const*/ Settings s = settings;
93 s.showtime = opt.showtime;
94 s.quiet = opt.quiet;
95 if (opt.plistOutput)
96 s.plistOutput = opt.plistOutput;
97 s.templateFormat = "{callstack}: ({severity}) {inconclusive:inconclusive: }{message}"; // TODO: remove when we only longer rely on toString() in unique message handling?
98
99 Suppressions supprs;
100 std::unique_ptr<TimerResults> timerResults;
101 if (s.showtime != Settings::ShowTime::NONE)
102 timerResults.reset(new TimerResults);
103
104 // NOLINTNEXTLINE(performance-unnecessary-value-param)
105 CppCheck cppcheck(s, supprs, *this, timerResults.get(), true, [](std::string,std::vector<std::string>,std::string,std::string&){
106 return EXIT_SUCCESS;
107 });
108
109 std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
110 scopedfiles.reserve(filelist.size());
111 for (auto i = filelist.cbegin(); i != filelist.cend(); ++i)
112 scopedfiles.emplace_back(new ScopedFile(i->path(), data));
113
114 // clear files list so only fileSettings are used
115 if (useFS)
116 filelist.clear();
117
118 SingleExecutor executor(cppcheck, filelist, fileSettings, s, supprs, *this, timerResults.get());
119 ASSERT_EQUALS(result, executor.check());
120 }
121
122 void run() override {
123 mNewTemplate = true;

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45
getMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected