GCC Code Coverage Report


Directory: ./
File: tasks/posternak_a_count_different_char_in_two_lines/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 5 5 100.0%
Branches: 9 12 75.0%

Line Branch Exec Source
1 #include "posternak_a_count_different_char_in_two_lines/seq/include/ops_seq.hpp"
2
3 #include <cstddef>
4 #include <string>
5 #include <utility>
6
7 #include "posternak_a_count_different_char_in_two_lines/common/include/common.hpp"
8
9 namespace posternak_a_count_different_char_in_two_lines {
10
11
1/2
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
160 PosternakACountDifferentCharInTwoLinesSEQ::PosternakACountDifferentCharInTwoLinesSEQ(const InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13 GetInput() = in;
14 160 GetOutput() = 0;
15 160 }
16
17 160 bool PosternakACountDifferentCharInTwoLinesSEQ::ValidationImpl() {
18 std::pair<std::string, std::string> &lines = GetInput();
19 std::string s1 = lines.first;
20 std::string s2 = lines.second;
21
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
320 return !s1.empty() && !s2.empty();
22 }
23
24 160 bool PosternakACountDifferentCharInTwoLinesSEQ::PreProcessingImpl() {
25 160 return true;
26 }
27 160 bool PosternakACountDifferentCharInTwoLinesSEQ::RunImpl() {
28 std::pair<std::string, std::string> &lines = GetInput();
29 std::string s1 = lines.first;
30 std::string s2 = lines.second;
31
32 int diff_count = 0;
33 size_t min = 0;
34 size_t max = 0;
35 size_t s1_len = s1.length();
36 size_t s2_len = s2.length();
37
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 144 times.
160 if (s1_len >= s2_len) {
38 min = s2_len;
39 max = s1_len;
40 } else {
41 min = s1_len;
42 max = s2_len;
43 }
44
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 160 times.
1344 for (size_t i = 0; i < min; i++) {
45
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 944 times.
1184 if (s1[i] != s2[i]) {
46 240 diff_count++;
47 }
48 }
49
50 160 diff_count += static_cast<int>(max - min);
51 160 GetOutput() = diff_count;
52 160 return true;
53 }
54
55 160 bool PosternakACountDifferentCharInTwoLinesSEQ::PostProcessingImpl() {
56 160 return true;
57 }
58
59 } // namespace posternak_a_count_different_char_in_two_lines
60