GCC Code Coverage Report


Directory: ./
File: tasks/kutergin_v_trapezoid_method_of_integration/seq/src/trapezoid_integration_sequential.cpp
Date: 2025-12-13 04:24:21
Exec Total Coverage
Lines: 21 22 95.5%
Functions: 5 6 83.3%
Branches: 4 6 66.7%

Line Branch Exec Source
1 #include "../include/trapezoid_integration_sequential.hpp"
2
3 #include "../../common/include/common.hpp"
4
5 namespace kutergin_v_trapezoid_seq {
6
7 double Func(double x) // интегрируемая функция для примера
8 {
9 505208 return x * x;
10 }
11
12 72 TrapezoidIntegrationSequential::TrapezoidIntegrationSequential(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask()); // установка типа задачи
14 72 GetInput() = in; // сохранение входных данных
15 GetOutput() = 0.0; // инициализация выходных данных
16 72 }
17
18 72 bool TrapezoidIntegrationSequential::ValidationImpl() {
19
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 return (GetInput().b >= GetInput().a) &&
20
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 (GetInput().n > 0); // проверка b >= a (границ интегрирования) и n > 0 (число разбиений)
21 }
22
23 72 bool TrapezoidIntegrationSequential::PreProcessingImpl() {
24 72 return true;
25 }
26
27 72 bool TrapezoidIntegrationSequential::RunImpl() {
28 72 double a = GetInput().a;
29 72 double b = GetInput().b;
30 72 int n = GetInput().n;
31
32 72 double h = (b - a) / n;
33 72 double integral_res = (Func(a) + Func(b)) / 2.0;
34
35
2/2
✓ Branch 0 taken 505136 times.
✓ Branch 1 taken 72 times.
505208 for (int i = 1; i < n; ++i) {
36 505136 integral_res += Func(a + (i * h));
37 }
38
39 72 GetOutput() = integral_res * h;
40
41 72 return true;
42 }
43
44 72 bool TrapezoidIntegrationSequential::PostProcessingImpl() {
45 72 return true;
46 }
47
48 } // namespace kutergin_v_trapezoid_seq
49