GCC Code Coverage Report


Directory: ./
File: tasks/pankov_a_string_word_count/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 19 19 100.0%
Functions: 6 6 100.0%
Branches: 7 8 87.5%

Line Branch Exec Source
1 #include "pankov_a_string_word_count/seq/include/ops_seq.hpp"
2
3 #include <cctype>
4 #include <string>
5
6 #include "pankov_a_string_word_count/common/include/common.hpp"
7
8 namespace pankov_a_string_word_count {
9
10
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 PankovAStringWordCountSEQ::PankovAStringWordCountSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12 GetInput() = in;
13 64 GetOutput() = 0;
14 64 }
15
16 64 bool PankovAStringWordCountSEQ::ValidationImpl() {
17 64 return GetOutput() == 0;
18 }
19
20 64 bool PankovAStringWordCountSEQ::PreProcessingImpl() {
21 64 GetOutput() = 0;
22 64 return true;
23 }
24
25 namespace {
26
27 64 OutType CountWordsInString(const std::string &s) {
28 int count = 0;
29 bool in_word = false;
30
31
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 64 times.
1344 for (unsigned char uc : s) {
32
2/2
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 392 times.
1280 if (std::isspace(uc) == 0) {
33
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 552 times.
888 if (!in_word) {
34 in_word = true;
35 336 ++count;
36 }
37 } else {
38 in_word = false;
39 }
40 }
41
42 64 return count;
43 }
44
45 } // namespace
46
47 64 bool PankovAStringWordCountSEQ::RunImpl() {
48 const std::string &s = GetInput();
49 64 GetOutput() = CountWordsInString(s);
50 64 return true;
51 }
52
53 64 bool PankovAStringWordCountSEQ::PostProcessingImpl() {
54 64 return GetOutput() >= 0;
55 }
56
57 } // namespace pankov_a_string_word_count
58