Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
DenTerNG committed May 15, 2024
1 parent 2b3d8f7 commit 816a1da
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
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
35 changes: 35 additions & 0 deletions test_visitor.cpp
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();
}

2 changes: 1 addition & 1 deletion third-party/gtest
Submodule gtest updated 74 files
+43 −0 .github/workflows/gtest-ci.yml
+0 −1 .gitignore
+0 −17 BUILD.bazel
+1 −10 CMakeLists.txt
+4 −4 CONTRIBUTING.md
+0 −1 CONTRIBUTORS
+0 −61 MODULE.bazel
+8 −8 README.md
+12 −14 WORKSPACE
+0 −35 WORKSPACE.bzlmod
+4 −6 ci/linux-presubmit.sh
+1 −2 ci/macos-presubmit.sh
+2 −2 ci/windows-presubmit.bat
+12 −22 docs/advanced.md
+39 −18 docs/faq.md
+3 −38 docs/gmock_cook_book.md
+2 −4 docs/gmock_for_dummies.md
+20 −19 docs/primer.md
+1 −1 docs/reference/assertions.md
+2 −1 docs/reference/mocking.md
+4 −8 docs/reference/testing.md
+0 −33 fake_fuchsia_sdk.bzl
+13 −14 googlemock/CMakeLists.txt
+3 −3 googlemock/README.md
+10 −34 googlemock/include/gmock/gmock-actions.h
+4 −5 googlemock/include/gmock/gmock-function-mocker.h
+89 −90 googlemock/include/gmock/gmock-matchers.h
+3 −4 googlemock/include/gmock/gmock-more-actions.h
+7 −8 googlemock/include/gmock/gmock.h
+6 −8 googlemock/include/gmock/internal/gmock-internal-utils.h
+4 −4 googlemock/include/gmock/internal/gmock-port.h
+2 −3 googlemock/src/gmock-internal-utils.cc
+1 −1 googlemock/src/gmock-matchers.cc
+1 −2 googlemock/src/gmock-spec-builders.cc
+0 −9 googlemock/test/gmock-matchers-comparisons_test.cc
+1 −39 googlemock/test/gmock-more-actions_test.cc
+1 −1 googlemock/test/gmock-spec-builders_test.cc
+0 −9 googlemock/test/gmock_link_test.h
+14 −14 googletest/CMakeLists.txt
+2 −2 googletest/README.md
+0 −4 googletest/cmake/Config.cmake.in
+20 −22 googletest/cmake/internal_utils.cmake
+1 −1 googletest/include/gtest/gtest-assertion-result.h
+4 −4 googletest/include/gtest/gtest-death-test.h
+10 −9 googletest/include/gtest/gtest-message.h
+4 −4 googletest/include/gtest/gtest-param-test.h
+27 −63 googletest/include/gtest/gtest-printers.h
+61 −65 googletest/include/gtest/gtest-typed-test.h
+19 −36 googletest/include/gtest/gtest.h
+26 −25 googletest/include/gtest/internal/gtest-death-test-internal.h
+1 −7 googletest/include/gtest/internal/gtest-filepath.h
+69 −30 googletest/include/gtest/internal/gtest-internal.h
+75 −79 googletest/include/gtest/internal/gtest-param-util.h
+0 −2 googletest/include/gtest/internal/gtest-port-arch.h
+43 −98 googletest/include/gtest/internal/gtest-port.h
+17 −19 googletest/src/gtest-death-test.cc
+1 −1 googletest/src/gtest-filepath.cc
+17 −29 googletest/src/gtest-internal-inl.h
+28 −70 googletest/src/gtest-port.cc
+112 −163 googletest/src/gtest.cc
+0 −1 googletest/test/googletest-color-test.py
+37 −39 googletest/test/googletest-death-test-test.cc
+0 −15 googletest/test/googletest-json-output-unittest.py
+1 −4 googletest/test/googletest-options-test.cc
+5 −0 googletest/test/googletest-output-test-golden-lin.txt
+3 −3 googletest/test/googletest-port-test.cc
+0 −16 googletest/test/googletest-printers-test.cc
+44 −52 googletest/test/gtest_environment_test.cc
+41 −23 googletest/test/gtest_help_test.py
+0 −3 googletest/test/gtest_json_test_utils.py
+3 −1 googletest/test/gtest_repeat_test.cc
+27 −19 googletest/test/gtest_unittest.cc
+6 −9 googletest/test/gtest_xml_output_unittest.py
+8 −14 googletest_deps.bzl

0 comments on commit 816a1da

Please sign in to comment.