Skip to content

Commit

Permalink
(#290) Fix ошибок и unit тест на отрицание
Browse files Browse the repository at this point in the history
  • Loading branch information
dak151449 committed Nov 9, 2023
1 parent 47ddf77 commit 3ba9ca3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions apps/UnitTestsApp/src/UnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
#include "gtest/gtest.h"
#include <functional>

TEST(TestCaseName, Test_regex_minus) {

Check warning on line 13 in apps/UnitTestsApp/src/UnitTests.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/apps/UnitTestsApp/src/UnitTests.cpp:13:1 [modernize-use-trailing-return-type]

use a trailing return type for this function

Check warning on line 13 in apps/UnitTestsApp/src/UnitTests.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/apps/UnitTestsApp/src/UnitTests.cpp:13:18 [readability-named-parameter]

all parameters should be named in a function
string str = "^(c^(a^(b)d))e";

Check warning on line 14 in apps/UnitTestsApp/src/UnitTests.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/apps/UnitTestsApp/src/UnitTests.cpp:14:9 [cppcoreguidelines-init-variables]

variable 'str' is not initialized
Regex r1(str);

Check warning on line 15 in apps/UnitTestsApp/src/UnitTests.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/apps/UnitTestsApp/src/UnitTests.cpp:15:8 [cppcoreguidelines-init-variables]

variable 'r1' is not initialized
string r1_str = r1.to_txt();

Check warning on line 16 in apps/UnitTestsApp/src/UnitTests.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/apps/UnitTestsApp/src/UnitTests.cpp:16:9 [cppcoreguidelines-init-variables]

variable 'r1_str' is not initialized
Regex r2(r1_str);

Check warning on line 17 in apps/UnitTestsApp/src/UnitTests.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/apps/UnitTestsApp/src/UnitTests.cpp:17:8 [cppcoreguidelines-init-variables]

variable 'r2' is not initialized
ASSERT_EQ(true, Regex::equivalent(r1, r2));
}

TEST(TestCaseName, Test_random_regex_parsing) {

Check warning on line 21 in apps/UnitTestsApp/src/UnitTests.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/apps/UnitTestsApp/src/UnitTests.cpp:21:1 [modernize-use-trailing-return-type]

use a trailing return type for this function
RegexGenerator rg(15, 10, 5, 3);
for (int i = 0; i < 30; i++) {
Expand Down
2 changes: 1 addition & 1 deletion libs/Objects/src/AlgExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ string AlgExpression::to_txt() const {
if (term_l && term_l->type == Type::alt) {
str1 = "(" + str1 + ")";
}
if (term_r && term_l->type == Type::alt) {
if (term_r && term_r->type == Type::alt) {
str2 = "(" + str2 + ")";
}
break;
Expand Down
5 changes: 3 additions & 2 deletions libs/Objects/src/BackRefRegex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,23 @@ template <typename T> const BackRefRegex* BackRefRegex::cast(const T* ptr) {
}

string BackRefRegex::to_txt() const {
BackRefRegex* br_term_l;
BackRefRegex* br_term_l, *br_term_r;
string str1, str2;
if (term_l) {
str1 = term_l->to_txt();
br_term_l = cast(term_l);
}
if (term_r) {
str2 = term_r->to_txt();
br_term_r = cast(term_r);
}
string symb;
switch (type) {
case Type::conc:
if (term_l && br_term_l->type == Type::alt) {
str1 = "(" + str1 + ")";
}
if (term_r && br_term_l->type == Type::alt) {
if (term_r && br_term_r->type == Type::alt) {
str2 = "(" + str2 + ")";
}
break;
Expand Down

0 comments on commit 3ba9ca3

Please sign in to comment.