MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / WriteLCOV

Method WriteLCOV

testing/testrunner/coverage_index.cc:225–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225void CoverageIndex::WriteLCOV(absl::string_view path) {
226 std::ofstream file(std::string(path).c_str());
227 if (!file.is_open()) {
228 return;
229 }
230
231 // Maps instrumented line numbers to whether they are covered.
232 std::map<int, bool> lines;
233 const auto& positions = checked_expr_.source_info().positions();
234 for (const auto& [node_id, stats] : node_coverage_stats_) {
235 auto it = positions.find(node_id);
236 if (it == positions.end()) continue;
237 int line_num = GetLineNumber(checked_expr_.source_info(), it->second);
238 bool& covered = lines[line_num];
239 covered = covered || stats.covered;
240 }
241
242 file << "SF:" << checked_expr_.source_info().location() << "\n";
243 for (auto& [line_num, covered] : lines) {
244 file << "DA:" << line_num << "," << (covered ? 1 : 0) << "\n";
245 }
246 file << "end_of_record\n";
247}
248
249InstrumentationFactory InstrumentationFactoryForCoverage(
250 CoverageIndex& coverage_index) {

Callers 1

TESTFunction · 0.80

Calls 4

GetLineNumberFunction · 0.85
source_infoMethod · 0.80
locationMethod · 0.80
endMethod · 0.45

Tested by 1

TESTFunction · 0.64