| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "polukhin_v_string_diff/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cmath> | ||
| 5 | #include <cstddef> | ||
| 6 | #include <string> | ||
| 7 | |||
| 8 | #include "polukhin_v_string_diff/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace polukhin_v_string_diff { | ||
| 11 | |||
| 12 |
1/2✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
|
88 | StringDiffTaskSEQ::StringDiffTaskSEQ(const InType &in) { |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 | GetInput() = in; | ||
| 15 | 88 | GetOutput() = 0; | |
| 16 | 88 | } | |
| 17 | |||
| 18 | 88 | bool StringDiffTaskSEQ::ValidationImpl() { | |
| 19 | 88 | return true; | |
| 20 | } | ||
| 21 | |||
| 22 | 88 | bool StringDiffTaskSEQ::PreProcessingImpl() { | |
| 23 | 88 | return true; | |
| 24 | } | ||
| 25 | |||
| 26 | 88 | bool StringDiffTaskSEQ::RunImpl() { | |
| 27 | const auto &input = GetInput(); | ||
| 28 | const std::string &str1 = input.first; | ||
| 29 | const std::string &str2 = input.second; | ||
| 30 | |||
| 31 | size_t result = 0; | ||
| 32 | size_t min_len = std::min(str1.size(), str2.size()); | ||
| 33 | |||
| 34 |
2/2✓ Branch 0 taken 352 times.
✓ Branch 1 taken 88 times.
|
440 | for (size_t i = 0; i < min_len; ++i) { |
| 35 |
2/2✓ Branch 0 taken 176 times.
✓ Branch 1 taken 176 times.
|
352 | if (str1[i] != str2[i]) { |
| 36 | 176 | ++result; | |
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | size_t len1 = str1.size(); | ||
| 41 | size_t len2 = str2.size(); | ||
| 42 | 88 | result += (std::max<size_t>(len1, len2) - std::min<size_t>(len1, len2)); | |
| 43 | |||
| 44 | 88 | GetOutput() = result; | |
| 45 | 88 | return true; | |
| 46 | } | ||
| 47 | |||
| 48 | 88 | bool StringDiffTaskSEQ::PostProcessingImpl() { | |
| 49 | 88 | return true; | |
| 50 | } | ||
| 51 | |||
| 52 | } // namespace polukhin_v_string_diff | ||
| 53 |