GCC Code Coverage Report


Directory: ./
File: tasks/akhmetov_daniil_integration_monte_carlo/common/include/common.hpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 22 24 91.7%
Functions: 2 2 100.0%
Branches: 10 12 83.3%

Line Branch Exec Source
1 #pragma once
2
3 #include <cmath>
4 #include <cstdint>
5 #include <string>
6 #include <tuple>
7
8 #include "task/include/task.hpp"
9
10 namespace akhmetov_daniil_integration_monte_carlo {
11
12 enum class FuncType : std::uint8_t {
13 kLinearFunc = 0, // 3x + 2
14 kQuadraticFunc = 1, // x² + 1
15 kSinFunc = 2, // sin(x)
16 kExpFunc = 3, // e^x
17 kConstFunc = 4 // 5 (const)
18 };
19
20 class FunctionPair {
21 public:
22 13050000 static double Function(FuncType func_id, double x) {
23
5/6
✓ Branch 0 taken 2250000 times.
✓ Branch 1 taken 2700000 times.
✓ Branch 2 taken 4500000 times.
✓ Branch 3 taken 2700000 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 900000 times.
13050000 switch (func_id) {
24 2250000 case FuncType::kLinearFunc:
25 2250000 return (3.0 * x) + 2.0;
26 2700000 case FuncType::kQuadraticFunc:
27 2700000 return (x * x) + 1.0;
28 4500000 case FuncType::kSinFunc:
29 4500000 return std::sin(x);
30 2700000 case FuncType::kExpFunc:
31 2700000 return std::exp(x);
32 case FuncType::kConstFunc:
33 return 5.0;
34 default:
35 return 0.0;
36 }
37 }
38
39 200 static double Integral(FuncType func_id, double x) {
40
5/6
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 40 times.
✓ Branch 4 taken 40 times.
✗ Branch 5 not taken.
200 switch (func_id) {
41 40 case FuncType::kLinearFunc:
42 40 return (1.5 * x * x) + (2.0 * x);
43 40 case FuncType::kQuadraticFunc:
44 40 return (x * x * x / 3.0) + x;
45 40 case FuncType::kSinFunc:
46 40 return -std::cos(x);
47 40 case FuncType::kExpFunc:
48 40 return std::exp(x);
49 40 case FuncType::kConstFunc:
50 40 return 5.0 * x;
51 default:
52 return 0.0;
53 }
54 }
55 };
56
57 using InType = std::tuple<double, double, int, FuncType>;
58 using OutType = double;
59 using TestType = std::tuple<std::tuple<double, double, int, FuncType>, std::string>;
60 using BaseTask = ppc::task::Task<InType, OutType>;
61
62 } // namespace akhmetov_daniil_integration_monte_carlo
63