GCC Code Coverage Report


Directory: ./
File: tasks/chetverikova_e_shell_sort_simple_merge/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 37 38 97.4%
Functions: 7 7 100.0%
Branches: 34 54 63.0%

Line Branch Exec Source
1 #include "chetverikova_e_shell_sort_simple_merge/seq/include/ops_seq.hpp"
2
3 #include <cstddef>
4 #include <vector>
5
6 #include "chetverikova_e_shell_sort_simple_merge/common/include/common.hpp"
7
8 namespace chetverikova_e_shell_sort_simple_merge {
9
10
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 ChetverikovaEShellSortSimpleMergeSEQ::ChetverikovaEShellSortSimpleMergeSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 GetInput() = in;
13 GetOutput().clear();
14 24 }
15
16 24 bool ChetverikovaEShellSortSimpleMergeSEQ::ValidationImpl() {
17 24 return !(GetInput().empty());
18 }
19
20 24 bool ChetverikovaEShellSortSimpleMergeSEQ::PreProcessingImpl() {
21 24 return true;
22 }
23
24
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 void ChetverikovaEShellSortSimpleMergeSEQ::ShellSort(std::vector<int> &data) {
25
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if (data.empty()) {
26 return;
27 }
28
29 size_t n = data.size();
30
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 48 times.
144 for (size_t gap = n / 2; gap > 0; gap /= 2) {
31
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 96 times.
480 for (size_t i = gap; i < n; i++) {
32 384 int temp = data[i];
33 size_t j = i;
34
35
4/4
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 240 times.
608 while (j >= gap && data[j - gap] > temp) {
36 224 data[j] = data[j - gap];
37 j -= gap;
38 }
39
40 384 data[j] = temp;
41 }
42 }
43 }
44
45 24 std::vector<int> ChetverikovaEShellSortSimpleMergeSEQ::MergeSort(const std::vector<int> &left,
46 const std::vector<int> &right) {
47
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 std::vector<int> result;
48
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 result.reserve(left.size() + right.size());
49 size_t i = 0;
50 size_t j = 0;
51
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 176 times.
200 while (i < left.size() && j < right.size()) {
52
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 128 times.
176 if (left[i] <= right[j]) {
53
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 result.push_back(left[i++]);
54 } else {
55
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 result.push_back(right[j++]);
56 }
57 }
58
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 24 times.
96 while (i < left.size()) {
59
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 result.push_back(left[i++]);
60 }
61
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 24 times.
32 while (j < right.size()) {
62
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 result.push_back(right[j++]);
63 }
64
65 24 return result;
66 }
67
68
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 bool ChetverikovaEShellSortSimpleMergeSEQ::RunImpl() {
69 const auto &input = GetInput();
70 auto &output = GetOutput();
71
72
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (input.empty()) {
73 GetOutput().clear();
74 return true;
75 }
76
77 24 const size_t mid = input.size() / 2;
78
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 std::vector<int> left(input.begin(), input.begin() + static_cast<std::ptrdiff_t>(mid));
79
1/4
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 std::vector<int> right(input.begin() + static_cast<std::ptrdiff_t>(mid), input.end());
80 24 ShellSort(left);
81 24 ShellSort(right);
82
83
2/6
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
48 output = MergeSort(left, right);
84
85 return true;
86 }
87
88 24 bool ChetverikovaEShellSortSimpleMergeSEQ::PostProcessingImpl() {
89 24 return true;
90 }
91
92 } // namespace chetverikova_e_shell_sort_simple_merge
93