diff options
author | Marco Bubke <marco.bubke@qt.io> | 2017-12-27 20:44:34 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-01-16 14:00:28 +0000 |
commit | 5d088e9df5b818aee0893bab9467f19b7297597b (patch) | |
tree | 874ddc67769657f7f247454837a6ae25c9984109 /tests | |
parent | 40383715f758ce41d1ed03d904e6cf66e15db5da (diff) |
UnitTests: Cleanup unit tests
There was still unneeded PrintTo functions and gtest includes.
It is now possible to use MockFunction for callbacks.
Change-Id: Ie5875c3697069a37b48c2f2022f1f8c21f1c794f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/mockup/texteditor/refactoringchanges.h | 7 | ||||
-rw-r--r-- | tests/unit/unittest/gmock_dependency.pri | 14 | ||||
-rw-r--r-- | tests/unit/unittest/googletest.h | 2 | ||||
-rw-r--r-- | tests/unit/unittest/gtest-creator-printing.cpp | 21 | ||||
-rw-r--r-- | tests/unit/unittest/gtest-creator-printing.h | 10 |
5 files changed, 34 insertions, 20 deletions
diff --git a/tests/unit/mockup/texteditor/refactoringchanges.h b/tests/unit/mockup/texteditor/refactoringchanges.h index 9911bab3cd..53eda6288e 100644 --- a/tests/unit/mockup/texteditor/refactoringchanges.h +++ b/tests/unit/mockup/texteditor/refactoringchanges.h @@ -25,6 +25,8 @@ #pragma once +#include "googletest.h" + #include <QFile> #include <QSharedPointer> #include <QTextBlock> @@ -35,11 +37,6 @@ #include <memory> -#include "gtest/gtest.h" -#include "gmock/gmock-matchers.h" -#include "gmock/gmock.h" -#include "gtest-qt-printing.h" - QT_BEGIN_NAMESPACE class QString; QT_END_NAMESPACE diff --git a/tests/unit/unittest/gmock_dependency.pri b/tests/unit/unittest/gmock_dependency.pri index a78f11b6a8..1af7b95f09 100644 --- a/tests/unit/unittest/gmock_dependency.pri +++ b/tests/unit/unittest/gmock_dependency.pri @@ -33,7 +33,19 @@ requires(exists($$GTEST_SRC_DIR):exists($$GMOCK_SRC_DIR)) DEFINES += \ GTEST_HAS_STD_INITIALIZER_LIST_ \ - GTEST_LANG_CXX11 + GTEST_LANG_CXX11 \ + GTEST_HAS_STD_TUPLE_ \ + GTEST_HAS_STD_TYPE_TRAITS_ \ + GTEST_HAS_STD_FUNCTION_ \ + GTEST_HAS_RTTI \ + GTEST_HAS_STD_BEGIN_AND_END_ \ + GTEST_HAS_STD_UNIQUE_PTR_ \ + GTEST_HAS_EXCEPTIONS \ + GTEST_HAS_STREAM_REDIRECTION \ + GTEST_HAS_TYPED_TEST \ + GTEST_HAS_TYPED_TEST_P \ + GTEST_HAS_PARAM_TEST \ + GTEST_HAS_DEATH_TEST INCLUDEPATH *= \ $$GTEST_INCLUDE_DIR \ diff --git a/tests/unit/unittest/googletest.h b/tests/unit/unittest/googletest.h index 550fdf4375..6b01852fe2 100644 --- a/tests/unit/unittest/googletest.h +++ b/tests/unit/unittest/googletest.h @@ -28,7 +28,7 @@ #include <gmock/gmock.h> #include <gmock/gmock-matchers.h> #include <gtest/gtest.h> - +#include <gtest/gtest-printers.h> #include "compare-operators.h" #include "conditionally-disabled-tests.h" diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 2c106ec0e5..4d463682c3 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -41,6 +41,7 @@ #include <sourcelocationentry.h> #include <sourcelocationscontainer.h> #include <tokeninfos.h> +#include <filepathview.h> #include <cpptools/usages.h> @@ -121,6 +122,16 @@ std::ostream &operator<<(std::ostream &out, const FilePathId &id) return out << "(" << id.directoryId << ", " << id.fileNameId << ")"; } +std::ostream &operator<<(std::ostream &out, const FilePathView &filePathView) +{ + return out << "(" << filePathView.toStringView() << ", " << filePathView.slashIndex() << ")"; +} + +std::ostream &operator<<(std::ostream &out, const NativeFilePathView &nativeFilePathView) +{ + return out << "(" << nativeFilePathView.toStringView() << ", " << nativeFilePathView.slashIndex() << ")"; +} + std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths) { out << "(" @@ -720,16 +731,6 @@ std::ostream &operator<<(std::ostream &out, const FilePath &filePath) return out << "(" << filePath.path() << ", " << filePath.slashIndex() << ")"; } -void PrintTo(const FilePathId &id, ::std::ostream *os) -{ - *os << id; -} - -void PrintTo(const FilePath &filePath, ::std::ostream *os) -{ - *os << filePath; -} - namespace V2 { std::ostream &operator<<(std::ostream &os, const FileContainer &container) diff --git a/tests/unit/unittest/gtest-creator-printing.h b/tests/unit/unittest/gtest-creator-printing.h index e08b4b33c0..7fc9e15bf4 100644 --- a/tests/unit/unittest/gtest-creator-printing.h +++ b/tests/unit/unittest/gtest-creator-printing.h @@ -114,11 +114,14 @@ class UpdateVisibleTranslationUnitsMessage; class FilePath; class TokenInfo; class TokenInfos; +template <char WindowsSlash> +class AbstractFilePathView; +using FilePathView = AbstractFilePathView<'/'>; +using NativeFilePathView = AbstractFilePathView<'\\'>; std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry); std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths); std::ostream &operator<<(std::ostream &out, const WatcherEntry &entry); -std::ostream &operator<<(std::ostream &out, const FilePath &filePath); std::ostream &operator<<(std::ostream &out, const SourceLocationsContainer &container); std::ostream &operator<<(std::ostream &out, const RegisterProjectPartsForEditorMessage &message); std::ostream &operator<<(std::ostream &out, const CancelMessage &message); @@ -168,8 +171,11 @@ std::ostream &operator<<(std::ostream &out, const UpdatePchProjectPartsMessage & std::ostream &operator<<(std::ostream &out, const UpdateTranslationUnitsForEditorMessage &message); std::ostream &operator<<(std::ostream &out, const UpdateVisibleTranslationUnitsMessage &message); std::ostream &operator<<(std::ostream &out, const FilePath &filePath); +std::ostream &operator<<(std::ostream &out, const FilePathId &filePathId); std::ostream &operator<<(std::ostream &out, const TokenInfo& tokenInfo); std::ostream &operator<<(std::ostream &out, const TokenInfos &tokenInfos); +std::ostream &operator<<(std::ostream &out, const FilePathView &filePathView); +std::ostream &operator<<(std::ostream &out, const NativeFilePathView &nativeFilePathView); namespace V2 { class FileContainer; @@ -183,8 +189,6 @@ std::ostream &operator<<(std::ostream &out, const SourceLocationContainer &conta std::ostream &operator<<(std::ostream &out, const SourceRangeContainer &container); } // namespace V2 -void PrintTo(const FilePathId &id, ::std::ostream *os); -void PrintTo(const FilePath &filePath, ::std::ostream *os); } // namespace ClangBackEnd namespace ClangRefactoring { |