| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "krymova_k_lex_order/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <string> | ||
| 5 | |||
| 6 | #include "krymova_k_lex_order/common/include/common.hpp" | ||
| 7 | |||
| 8 | namespace krymova_k_lex_order { | ||
| 9 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | KrymovaKLexSEQ::KrymovaKLexSEQ(const InType &in) { |
| 10 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 11 | GetInput() = in; | ||
| 12 | 80 | GetOutput() = 0; | |
| 13 | 80 | } | |
| 14 | |||
| 15 | 80 | bool KrymovaKLexSEQ::ValidationImpl() { | |
| 16 | 80 | return true; | |
| 17 | } | ||
| 18 | |||
| 19 | 80 | bool KrymovaKLexSEQ::PreProcessingImpl() { | |
| 20 | 80 | return true; | |
| 21 | } | ||
| 22 | |||
| 23 | 80 | bool KrymovaKLexSEQ::RunImpl() { | |
| 24 | const std::string &str1 = std::get<0>(GetInput()); | ||
| 25 | const std::string &str2 = std::get<1>(GetInput()); | ||
| 26 | |||
| 27 | size_t len1 = str1.length(); | ||
| 28 | size_t len2 = str2.length(); | ||
| 29 | 80 | size_t min_len = (len1 < len2) ? len1 : len2; | |
| 30 | |||
| 31 | int result = 0; | ||
| 32 |
2/2✓ Branch 0 taken 152 times.
✓ Branch 1 taken 40 times.
|
192 | for (size_t i = 0; i < min_len; ++i) { |
| 33 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 112 times.
|
152 | if (str1[i] != str2[i]) { |
| 34 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 24 times.
|
40 | result = (str1[i] < str2[i]) ? -1 : 1; |
| 35 | break; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | if (result == 0) { | ||
| 39 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
|
40 | if (len1 < len2) { |
| 40 | result = -1; | ||
| 41 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
|
32 | } else if (len1 > len2) { |
| 42 | result = 1; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | 80 | GetOutput() = result; | |
| 47 | 80 | return true; | |
| 48 | } | ||
| 49 | |||
| 50 | 80 | bool KrymovaKLexSEQ::PostProcessingImpl() { | |
| 51 | 80 | return true; | |
| 52 | } | ||
| 53 | |||
| 54 | } // namespace krymova_k_lex_order | ||
| 55 |