GCC Code Coverage Report


Directory: ./
File: tasks/agafonov_i_sentence_count/seq/src/ops_seq.cpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 0 24 0.0%
Functions: 0 5 0.0%
Branches: 0 24 0.0%

Line Branch Exec Source
1 #include "agafonov_i_sentence_count/seq/include/ops_seq.hpp"
2
3 #include <cctype>
4 #include <string>
5
6 #include "agafonov_i_sentence_count/common/include/common.hpp"
7
8 namespace agafonov_i_sentence_count {
9
10 SentenceCountSEQ::SentenceCountSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12 GetInput() = in;
13 }
14
15 bool SentenceCountSEQ::ValidationImpl() {
16 return true;
17 }
18
19 bool SentenceCountSEQ::PreProcessingImpl() {
20 return true;
21 }
22
23 bool SentenceCountSEQ::RunImpl() {
24 const std::string &text = GetInput();
25 if (text.empty()) {
26 GetOutput() = 0;
27 return true;
28 }
29
30 int count = 0;
31 bool in_word = false;
32 int len = static_cast<int>(text.length());
33
34 for (int i = 0; i < len; ++i) {
35 auto c = static_cast<unsigned char>(text[i]);
36 if (std::isalnum(c) != 0) {
37 in_word = true;
38 } else if ((c == '.' || c == '!' || c == '?') && in_word) {
39 if (c == '.' && i + 1 < len && text[i + 1] == '.') {
40 continue;
41 }
42 count++;
43 in_word = false;
44 }
45 }
46
47 if (in_word) {
48 count++;
49 }
50
51 GetOutput() = count;
52 return true;
53 }
54
55 bool SentenceCountSEQ::PostProcessingImpl() {
56 return true;
57 }
58
59 } // namespace agafonov_i_sentence_count
60