GCC Code Coverage Report


Directory: ./
File: tasks/gasenin_l_mult_int_mstep_trapez/common/include/common.hpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 21 21 100.0%
Functions: 2 2 100.0%
Branches: 12 12 100.0%

Line Branch Exec Source
1 #pragma once
2
3 #include <cmath>
4 #include <functional>
5 #include <string>
6 #include <tuple>
7
8 #include "task/include/task.hpp"
9
10 namespace gasenin_l_mult_int_mstep_trapez {
11
12 struct TaskData {
13 int n_steps;
14 int func_id;
15 double x1, x2;
16 double y1, y2;
17
18 bool operator==(const TaskData &other) const {
19 return n_steps == other.n_steps && func_id == other.func_id && std::abs(x1 - other.x1) < 1e-9 &&
20 std::abs(x2 - other.x2) < 1e-9 && std::abs(y1 - other.y1) < 1e-9 && std::abs(y2 - other.y2) < 1e-9;
21 }
22 };
23
24 using InType = TaskData;
25 using OutType = double;
26 using TestType = std::tuple<TaskData, std::string>;
27 using BaseTask = ppc::task::Task<InType, OutType>;
28
29 136 inline std::function<double(double, double)> GetFunction(int id) {
30
6/6
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
136 switch (id) {
31 case 0:
32 488192 return [](double x, double y) { return x + y; };
33 case 1:
34 509488 return [](double x, double y) { return (x * x) + (y * y); };
35 case 2:
36 280344 return [](double x, double y) { return std::sin(x) * std::cos(y); };
37 case 3:
38 102416 return [](double x, double y) { return std::exp(x + y); };
39 case 4:
40 404816 return [](double x, double y) { return std::sqrt((x * x) + (y * y)); };
41 default:
42 return [](double x, double y) {
43 (void)x;
44 (void)y;
45 return 1.0;
46 };
47 }
48 }
49
50 170 inline double GetExactIntegral(const TaskData &data) {
51
6/6
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 20 times.
170 switch (data.func_id) {
52 50 case 0:
53 50 return (0.5 * ((data.x2 * data.x2) - (data.x1 * data.x1)) * (data.y2 - data.y1)) +
54 50 (0.5 * ((data.y2 * data.y2) - (data.y1 * data.y1)) * (data.x2 - data.x1));
55 30 case 1:
56 30 return ((1.0 / 3.0) * ((data.x2 * data.x2 * data.x2) - (data.x1 * data.x1 * data.x1)) * (data.y2 - data.y1)) +
57 30 ((1.0 / 3.0) * ((data.y2 * data.y2 * data.y2) - (data.y1 * data.y1 * data.y1)) * (data.x2 - data.x1));
58 30 case 2:
59 30 return (std::cos(data.x1) - std::cos(data.x2)) * (std::sin(data.y2) - std::sin(data.y1));
60 20 case 3: {
61 20 return (std::exp(data.x2) - std::exp(data.x1)) * (std::exp(data.y2) - std::exp(data.y1));
62 }
63 20 case 5: {
64 20 return (data.x2 - data.x1) * (data.y2 - data.y1);
65 }
66 default:
67 return 0.0;
68 }
69 }
70
71 } // namespace gasenin_l_mult_int_mstep_trapez
72