-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: C++ CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install g++ | ||
sudo apt-get install libgtest-dev | ||
cd /usr/src/gtest | ||
sudo cmake CMakeLists.txt | ||
sudo make | ||
sudo cp *.a /usr/lib | ||
- name: Build and test | ||
run: | | ||
g++ -o visitor visitor.cpp -lgtest -lpthread | ||
g++ -o test_visitor test_visitor.cpp visitor.cpp -lgtest -lpthread | ||
./test_visitor | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "gtest/gtest.h" | ||
|
||
// Тестирование ConcreteVisitor1 | ||
class ConcreteVisitor1Test : public ::testing::Test { | ||
protected: | ||
ConcreteVisitor1 visitor; | ||
ConcreteElementA elementA; | ||
}; | ||
|
||
TEST_F(ConcreteVisitor1Test, VisitElementA) { | ||
testing::internal::CaptureStdout(); | ||
elementA.accept(visitor); | ||
std::string output = testing::internal::GetCapturedStdout(); | ||
EXPECT_EQ(output, "Concrete Visitor 1: Element A visited.\n"); | ||
} | ||
|
||
// Тестирование ConcreteElementA | ||
class ConcreteElementATest : public ::testing::Test { | ||
protected: | ||
ConcreteElementA elementA; | ||
ConcreteVisitor1 visitor; | ||
}; | ||
|
||
TEST_F(ConcreteElementATest, AcceptVisitor) { | ||
testing::internal::CaptureStdout(); | ||
elementA.accept(visitor); | ||
std::string output = testing::internal::GetCapturedStdout(); | ||
EXPECT_EQ(output, "Concrete Visitor 1: Element A visited.\n"); | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} | ||
|
Submodule gtest
updated
74 files