3884 Commits

Author SHA1 Message Date
Piotr Paczkowski (trzeci.eu)
cc05a3ca01
Define default destructor for test classes 2019-12-20 09:45:28 +01:00
Piotr Paczkowski (trzeci.eu)
05701fee28
Deleted functions as part of public interface 2019-12-20 09:41:58 +01:00
Piotr Paczkowski (trzeci.eu)
77b3a250ea
Review notes: Return T& from assignment operators 2019-12-20 09:39:06 +01:00
trzeci
9d8222ad66
Disable move constructor and assignment operator for test classes.
Disable move operations for TEST() and TEST_F() macros.
Previous implementation disabled only copy ctor and assing operator, but
this was violating rule of 5[1], which was captured by static code analysis tools
like clang-tidy `cppcoreguidelines-special-member-functions`.

[1]: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all
2019-12-17 23:43:31 +01:00
CJ Johnson
d166e09483 Merge pull request #2590 from kuzkry:remove-workaround_g++-stale-comments
PiperOrigin-RevId: 285812343
2019-12-16 16:03:59 -05:00
krzysio
0a0c826629 Googletest export
Don't use fully qualified ::std types in code examples.

Having a nested user-defined 'std' namespace anywhere in a program is a minefield and shouldn't be either explicitly supported or implicitly condoned.

PiperOrigin-RevId: 285790182
2019-12-16 16:03:51 -05:00
Shahbaz Youssefi
1800a38fb7 Revert "Googletest export": disallow empty prefix
This reverts commit 20b5b8ecc7a81d23b4716e22a2b35fd53379c8c6.
Reason for revert: Breaks existing applications, such as ANGLE
(angleproject.org), requires adding an extra prefix that needs to be
typed for no reason (when testing from command line) and increases the
logs' sizes by a non-trivial amount due to the very large number of
tests ANGLE runs.

Original commit message:

    Add a compile time check to ensure that the parameters to TEST_P and
    INSTANTIATE_TEST_SUITE_P are not empty. Some compilers already fail
    in that case and, even where it works, it's likely to result in
    technically invalid code by virtue of creating reserved identifiers:
    https://en.cppreference.com/w/cpp/language/identifiers

First, every project is perfectly capable of adding a prefix if they
want to support such a compiler. This change penalizes every
project.

Second, using a prefix such as `_p` also results in reserved
identifiers, so this change is not really solving the problem.  For that
matter, instead of generating `gtest_##prefix##...`, you can generate
`gtest_x##prefix##...` to correctly fix the issue, including when empty
prefixes are used.
2019-12-16 13:01:59 -05:00
Shahbaz Youssefi
4b7809c2f5 Revert "Googletest export": Remove test for empty prefix
This reverts commit 4c25e2b87fcb78abcfdee2739db9ed7a19754cd3.
Reason for revert: Reverting the commit that disallows empty prefixes.

Original commit message:

    Remove a test case rendered obsolete by disallowing empty argument for INSTANTIATE_TEST_SUITE_P.
    Remove the code that it was testing.
2019-12-16 13:01:52 -05:00
Shahbaz Youssefi
d201646906 Workaround VS bug w.r.t empty arguments to macros
Empty arguments can be passed to macros per C99 and C++11 specs, which
can then be forwarded to other macros.

Visual Studio's compiler has a bug in the following situation:

    #define A(x) #x
    #define B(x, y) A(x)
    B(, b)

In the above case, Visual Studio first expands x to nothing, then
complains that A is not invoked with the right amount of arguments.
However, x in A(x) is still one argument, even if it expands to no
preprocessing tokens.  See also https://stackoverflow.com/a/7674214.
2019-12-16 11:27:52 -05:00
Matt Calabrese
5b162a79d4 Merge pull request #2589 from kuzkry:remove-workaround_g++-no-space-after-first-macro-argument
PiperOrigin-RevId: 285255373
2019-12-13 12:58:11 -05:00
Abseil Team
d16f86ff1c Googletest export
Add GTEST_API_ to correct a build failure under MSCV.

PiperOrigin-RevId: 285208464
2019-12-13 12:58:02 -05:00
Abseil Team
d8eeb9760a Googletest export
Use C++11 variadic templates for ActionHelper in gmock-generated-actions.h.

Make ActionHelper use variadic templates to generate Perform static member function specializations instead of using pump.py syntax.

PiperOrigin-RevId: 284988441
2019-12-13 12:57:53 -05:00
Abseil Team
d442089d53 Googletest export
Detect when C++ parametric tests (TEST_P) are not instantiated.

When an un-instantiated TEST_P is found, a new test will be inserted that will emit a warning message.

This can be made to error with minor code edits.
In the future, that is intended to be the default.

PiperOrigin-RevId: 284901666
2019-12-13 12:57:44 -05:00
Matt Calabrese
88ba008c23 Merge pull request #2595 from kuzkry:remove-workaround_msvc-warning-4355
PiperOrigin-RevId: 284234675
2019-12-13 12:57:35 -05:00
Matt Calabrese
a3097c826e Merge pull request #2592 from kuzkry:remove-workaround_msvc-error-C2665
PiperOrigin-RevId: 284207090
2019-12-13 12:57:26 -05:00
misterg
6251071a20 Googletest export
Require all appveyor googletest windows builds to work on Pull Requests to increase CI coverage

PiperOrigin-RevId: 284206759
2019-12-13 12:57:17 -05:00
Ilya Kravchuk
20b8e7a1c8 Activate GNU extensions in case of MSYS generator 2019-12-13 13:47:04 +03:00
Mark Barolak
78fdd6c00b Merge pull request #2609 from kuzkry:revert-2596
PiperOrigin-RevId: 284041013
2019-12-06 11:34:42 -05:00
Abseil Team
9ed99c6c83 Googletest export
Change googletest to notice failures during SetUpTestSuite() and TearDownTestSuite().

Previously, errors that occurred during those functions were logged but otherwise ignored. After this change, such failures will cause the test to fail and a brief summary will be printed at the bottom of the test log.

See https://github.com/google/googletest/issues/2330.

PiperOrigin-RevId: 284033342
2019-12-06 11:34:34 -05:00
Abseil Team
2002f267f0 Googletest export
Update example Environment class destructor annotation

PiperOrigin-RevId: 283986183
2019-12-05 14:41:59 -05:00
Mark Barolak
1d563578c8 Merge pull request #2594 from kuzkry:remove-workaround_msvc-unneeded-const-dropping
PiperOrigin-RevId: 283979494
2019-12-05 14:41:50 -05:00
Abseil Team
cf75d4b92e Googletest export
Internal change

PiperOrigin-RevId: 283948137
2019-12-05 14:41:41 -05:00
Abseil Team
ae8d1fc81b Googletest export
Clarify use of IsTrue and IsFalse matchers.

These matchers are subtle and confusing: what are they for?
The docs in the code are clear, but not very accessible.
googletest/googlemock/include/gmock/gmock-more-matchers.h

PiperOrigin-RevId: 283393275
2019-12-02 16:42:01 -05:00
Mark Barolak
52825d78aa Merge pull request #2603 from maximilianschwab:patch-1
PiperOrigin-RevId: 283349646
2019-12-02 16:41:53 -05:00
Mark Barolak
11a9482f84 Merge pull request #2607 from oyefremov:patch-1
PiperOrigin-RevId: 283349621
2019-12-02 16:41:45 -05:00
Gennadiy Rozental
b155875f32 Merge pull request #2583 from ChristophStrehle:master
PiperOrigin-RevId: 282817206
2019-11-27 16:20:38 -05:00
Krystian Kuzniarek
3957b8898b Revert "remove MSVC workaround: wmain link error in the static library"
This reverts commit 298a40f023e6813d2bf73847c3a38ceaf5e46320.
2019-11-27 15:01:03 +01:00
Krystian Kuzniarek
967d8e05c2 Revert "unify googletest and googlemock main functions"
This reverts commit a909becdc599c46bcb57346b6123cb57cd07d15d.
2019-11-27 15:00:52 +01:00
Oleksandr Yefremov
b8a92f7c86
Rename test case to test suite 2019-11-27 10:30:03 +02:00
Gennadiy Rozental
34e92be31c Merge pull request #2604 from matepek:readme-update-with-opensource-proj
PiperOrigin-RevId: 282620313
2019-11-26 15:47:46 -05:00
Gennadiy Rozental
39803f3c51 Merge pull request #2593 from kuzkry:remove-workaround_msvc-namespace-scope-from-nested-class
PiperOrigin-RevId: 282593823
2019-11-26 15:47:38 -05:00
Gennadiy Rozental
0361bdf591 Merge pull request #2596 from kuzkry:remove-workaround_msvc-wmain-link-error
PiperOrigin-RevId: 282589492
2019-11-26 15:47:30 -05:00
Gennadiy Rozental
db13ff1f0b Merge pull request #2597 from kuzkry:remove-workaround_Nokia-Sybian-SafeMatcherCastImpl
PiperOrigin-RevId: 282581402
2019-11-26 15:47:21 -05:00
Abseil Team
be74b4b2e0 Googletest export
Wrap call to std::numeric_limits<>::max into round braces to appease MSVC.

Closes #2589

PiperOrigin-RevId: 282581361
2019-11-26 15:47:13 -05:00
Gennadiy Rozental
7a8a5bcec0 Merge pull request #2591 from kuzkry:remove-workaround_g++-using-on-operator<<
PiperOrigin-RevId: 282575040
2019-11-26 15:47:05 -05:00
Gennadiy Rozental
a32a200094 Merge pull request #2588 from kuzkry:remove-workaround_g++-incorrect-comments
PiperOrigin-RevId: 282568282
2019-11-26 15:46:55 -05:00
Abseil Team
51545ee515 Googletest export
Make generating goldens work with Python 3

golden_file.write(output) fails with Python 3 with:
TypeError: a bytes-like object is required, not 'str'
PiperOrigin-RevId: 282316101
2019-11-26 15:46:46 -05:00
Mate Pek
5a62d400e0 README.md: added Catch2 and Google Test Explorer 2019-11-25 23:53:49 +07:00
Maximilian Schwab
838a32845c
Fixed typo 2019-11-25 08:11:28 +01:00
Abseil Team
679bfec6db Googletest export
Fix typo in the predicate assertion table.

PiperOrigin-RevId: 281973457
2019-11-22 16:33:37 -05:00
Gennadiy Civil
af71b6607f Merge pull request #2570 from xieyubo:1.10
PiperOrigin-RevId: 281971090
2019-11-22 16:33:23 -05:00
Abseil Team
717ce7feb8 Googletest export
Use standard C++11 integer types in gtest-port.h.

Remove testing::internal::{Int,Uint}{32,64} in favor of types
guaranteed to be in <cstdint> since C++11.

Tests for built-in integer type coverage are switched from
{Int,Uint}64 to [unsigned] long long, which is guaranteed by
C++11 to exist and be at least 64-bit wide.

PiperOrigin-RevId: 281565263
2019-11-22 16:33:15 -05:00
Krystian Kuzniarek
a909becdc5 unify googletest and googlemock main functions 2019-11-22 17:45:04 +01:00
Krystian Kuzniarek
298a40f023 remove MSVC workaround: wmain link error in the static library 2019-11-22 17:45:04 +01:00
Krystian Kuzniarek
bbbc5d8a4b remove Nokia's Symbian compiler workaround: SafeMatcherCastImpl 2019-11-22 17:25:34 +01:00
Krystian Kuzniarek
e0c80b0a6e consistency fix for SafeMatcherCastImpl member functions 2019-11-22 17:25:34 +01:00
Krystian Kuzniarek
6748df1eab remove MSVC workaround: cease const dropping 2019-11-22 17:17:41 +01:00
Krystian Kuzniarek
ecefcbd4aa remove MSVC workaround: warning 4355 2019-11-22 17:15:23 +01:00
Krystian Kuzniarek
a5136dbdd2 remove MSVC workaround: error C2665 2019-11-22 17:12:11 +01:00
Krystian Kuzniarek
21d276b5c4 remove MSVC workaround: accessing namespace scope from within nested classes 2019-11-22 17:10:39 +01:00
Krystian Kuzniarek
a91e4e73b7 remove stale comments about older GCC versions 2019-11-22 17:09:52 +01:00
Krystian Kuzniarek
e1dd49835e remove g++ 2.95.0 workaround: no space after first comma in macros 2019-11-22 17:09:03 +01:00
Krystian Kuzniarek
2241be0c3f remove g++ 3.3 workaround: using on operator<< 2019-11-22 17:08:14 +01:00
Christoph Strehle
6a9d6d5c28 Fix compile break for Microsoft Visual Studio 2017 v141
This is a workaround, for those who have to compile with v141 build tools,
for a bug in msvc that the compiler can't compile the WithArgsAction.

see the following link for more details:
https://developercommunityapi.westus.cloudapp.azure.com/content/problem/420339/googlemocks-withargs-doesnt-compile-with-permissiv.html
2019-11-21 14:58:09 +01:00
Gennadiy Civil
200ff59949 Merge pull request #2569 from bgianfo:master
PiperOrigin-RevId: 281321427
2019-11-20 14:16:54 -05:00
Abseil Team
4bf466236d Googletest export
Add a breadcrumb about nullopt comparison near the Optional() matcher.

Also add a note about how otherwise-spurious 'Eq()' may be needed in some cases. Without this, something like Field(&MyStruct::optional_field_without_equals_equals, absl::nullopt) doesn't work - it converts the nullopt to an optional<> of the non-equalable type, and fails to select the operator==(optional<>, nullopt_t) overload. The Eq() lets the type persist later into the match.

PiperOrigin-RevId: 281305519
2019-11-20 14:16:45 -05:00
Abseil Team
50cfbb726b Googletest export
Update stale comments to point to proper location.

PiperOrigin-RevId: 281157036
2019-11-19 11:25:59 -05:00
xyb
dcdb65065f Fix internal memory leak in Windows _Crt report.
We use "MemoryIsNotDeallocated" to aovid internal expected leak reported
in Windows _Crt report, like:

    {
    #ifdef _MSC_VER
    	MemoryIsNotDeallocated memory_is_not_deeallocated;
    #endif

    	static ThreadIdToThreadLocals* map = new
	ThreadIdToThreadLocals();
	return map;
    }

But int the above code, only "new ThreadIdToThreadLocals()" is
protected, if we invoke "insert()" function of the return value,
the memory allocated in "insert()" will be reported to _Crt report
also. This change try to fix this issue.
2019-11-16 09:13:52 -08:00
Brian Gianforcaro
0c469a5a06 Fix FlatTuple compilation on older msvc.
googletest 1.10.0 fails to compile on msvc version 19.00.23917
with one compilation error:

src\googletest\include\gtest\internal\gtest-internal.h(1188) : error C2039:
'FlatTupleBase<testing::internal::FlatTuple<bool,bool>,testing::internal::IndexSequence<0,1> >':
is not a member of 'testing::internal::FlatTuple<bool,bool>'

This PR fixes the compilation error by explicitly specifying the full type that Indices is
located in the base type.
2019-11-15 17:41:40 -08:00
Andy Getz
c27acebba3 Merge pull request #2521 from Sinclair-John:master
PiperOrigin-RevId: 280666222
2019-11-15 17:30:15 -05:00
Andy Getz
f73898f3ff Merge pull request #2554 from kuzkry:update-gen_gtest_pred_impl
PiperOrigin-RevId: 279734102
2019-11-13 17:03:54 -05:00
Andy Getz
11440f27c6 Merge pull request #2556 from ienorand:avoid-pkg-config-lpthread-cflag
PiperOrigin-RevId: 279375858
2019-11-13 17:03:46 -05:00
Krystian Kuzniarek
dee725b053 add documentation for the premature-exit-file protocol 2019-11-11 17:17:52 +01:00
Abseil Team
d5707695cb Googletest export
Correctly deal with stringification, and forbid empty arguments where they could slip thought, in the type parameterized test API.

Note: even where empty args work, it's likely to result in technically invalid code by virtue of creating reserved identifiers:
https://en.cppreference.com/w/cpp/language/identifiers
PiperOrigin-RevId: 279330971
2019-11-08 15:47:19 -05:00
Abseil Team
681454dae4 Googletest export
Clone+exec death test allocates a single page of stack to run chdir + exec on.
This is not enough when gtest is built with ASan and run on particular
hardware.

With ASan on x86_64, ExecDeathTestChildMain has frame size of 1728 bytes.

Call to chdir() in ExecDeathTestChildMain ends up in
_dl_runtime_resolve_xsavec, which attempts to save register state on the stack;
according to cpuid(0xd) XSAVE register save area size is 2568 on my machine.

This results in something like this in all death tests:
  Result: died but not with expected error.
  ...
  [  DEATH   ] AddressSanitizer:DEADLYSIGNAL
  [  DEATH   ] =================================================================
  [  DEATH   ] ==178637==ERROR: AddressSanitizer: stack-overflow on address ...

PiperOrigin-RevId: 278709790
2019-11-08 15:47:12 -05:00
Xiaoyi Zhang
e08a460277 Merge pull request #2549 from kuzkry:pump-support-for-python-3
PiperOrigin-RevId: 278702666
2019-11-05 17:08:36 -05:00
Xiaoyi Zhang
8aedd597af Merge pull request #2548 from kuzkry:update-pump-manual
PiperOrigin-RevId: 278702531
2019-11-05 17:08:27 -05:00
Xiaoyi Zhang
54978626b4 Merge pull request #2547 from kuzkry:typo
PiperOrigin-RevId: 278702456
2019-11-05 17:08:18 -05:00
Xiaoyi Zhang
3e062a6efe Merge pull request #2373 from Youw:master
PiperOrigin-RevId: 278601074
2019-11-05 17:08:09 -05:00
Martin Erik Werner
6caa879a42 pkg-config: Remove pthread link flag from Cflags
Remove the threads link library variable references from the pkg-config
Cflags: field, removing -lpthread(s) from the compile flags.

"-l*" linker flags should only be part of the Libs: section and should
not be part of the Cflags: section in pkg-config files.

This was first suggested in
https://github.com/google/googletest/pull/2006 and further discussed in
https://github.com/google/googletest/pull/2483 .
2019-11-05 22:40:49 +01:00
Krystian Kuzniarek
f79ac2ce0e change incorrect comments 2019-11-05 06:55:32 +01:00
Krystian Kuzniarek
f9665846e4 update gen_gtest_pred_impl.py
After 7bd4a7f3 gtest_pred_impl_unittest.cc used to be newer than
its template.
2019-11-05 06:53:20 +01:00
Xiaoyi Zhang
8697709e03 Merge pull request #2453 from kuzkry:gtest-port-clean-up_kMaxBiggestInt
PiperOrigin-RevId: 278008286
2019-11-04 11:43:27 -05:00
Krystian Kuzniarek
f658561ef2 fix a typo 2019-11-02 01:18:21 +01:00
Krystian Kuzniarek
442f45b376 pump.py: add support for Python 3 2019-11-02 01:13:24 +01:00
Krystian Kuzniarek
523ad489ef update pump_manual.md 2019-11-02 01:08:24 +01:00
vslashg
e8a82dc7ed Merge pull request #2453 from kuzkry:gtest-port-clean-up_kMaxBiggestInt
PiperOrigin-RevId: 277979766
2019-11-01 16:02:16 -04:00
vslashg
057ee5063d Merge pull request #2533 from thejcannon:noexcept_spec
PiperOrigin-RevId: 277924721
2019-11-01 16:02:05 -04:00
Abseil Team
2db3df9c4f Googletest export
Change variable name to match comment.

PiperOrigin-RevId: 277713621
2019-10-31 15:11:41 -04:00
Abseil Team
e2fc3a9c9c Googletest export
Tolerate std::string's explicit copy construction from std::string_view.

PiperOrigin-RevId: 277583394
2019-10-31 15:11:31 -04:00
misterg
0a03480824 Googletest export
Remove outdated unsupported scripts

PiperOrigin-RevId: 277556831
2019-10-30 16:49:09 -04:00
Ihor Dutchak
f626deda19 Added special catch for std::exception in GTEST_TEST_NO_THROW_ 2019-10-30 21:57:48 +02:00
misterg
ba33a8876c Googletest export
Internal Change

PiperOrigin-RevId: 277336786
2019-10-29 16:51:58 -04:00
mhermas
fff8dabbf6 Googletest export
Merge 65032e28cba171c000accc85ffaf6f1e62921b86 into 8c91ecef292e963d23cd5b25f01ea1579fbe9aaa

Closes #2470

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/googletest/pull/2470 from hermas55:bugfix/default_const_param 65032e28cba171c000accc85ffaf6f1e62921b86
PiperOrigin-RevId: 277118535
2019-10-29 16:51:49 -04:00
Abseil Team
2bee6da24e Googletest export
Editorial cleanup of the "write the main function" section

PiperOrigin-RevId: 277102507
2019-10-29 16:51:40 -04:00
Abseil Team
755f853c6b Googletest export
Avoid temporary matcher instances.
They are unnecessary and can be relatively more expensive than the rest of the
algorithm.

PiperOrigin-RevId: 277084853
2019-10-29 16:51:31 -04:00
Abseil Team
757d39a79b Googletest export
Make it clearer that users should _not_ write their own main functions.

PiperOrigin-RevId: 277079721
2019-10-29 16:51:22 -04:00
vslashg
b5fb5ba05c Merge pull request #2527 from PiotrNycz:gmock_prevent_return_ref_to_store_temporaries_2
PiperOrigin-RevId: 277061341
2019-10-29 16:51:12 -04:00
Abseil Team
a1f71dd56d Googletest export
Remove badly formatted suggestion in gmock cheat sheet.

PiperOrigin-RevId: 277060475
2019-10-29 16:51:01 -04:00
vslashg
a8b1a66cfd Merge pull request #2388 from kuzkry:remove-gtest-type-util.pump
PiperOrigin-RevId: 276944601
2019-10-29 16:50:52 -04:00
Krystian Kuzniarek
1a49b67aeb update CONTRIBUTORS 2019-10-25 17:03:39 +02:00
Krystian Kuzniarek
002905f29f move the pumping script to googlemock 2019-10-25 17:03:39 +02:00
Krystian Kuzniarek
a7083564d5 remove gtest-type-util.h.pump 2019-10-25 17:03:39 +02:00
Krystian Kuzniarek
e3a9a567d8 replace autogenerated TemplatesX classes by variadic ones 2019-10-25 17:01:50 +02:00
Krystian Kuzniarek
eed64b5fc6 replace autogenerated TypesX classes by variadic ones 2019-10-25 16:58:35 +02:00
vslashg
540835fa68 Merge pull request #2515 from ciband:feat/support_esp8266
PiperOrigin-RevId: 276333426
2019-10-25 10:21:03 -04:00
Piotr Nycz
208c2f6b60 variable names corrected (followed google coding style)
Issue 2527
2019-10-25 16:14:18 +02:00
Piotr Nycz
5ff72f5295 Apply 80chars limit
Issue 2527
2019-10-25 10:29:15 +02:00
Piotr Nycz
d072682119 Tests simplified and names corrected (POD->scalar)
Issue 2527
2019-10-24 10:22:09 +02:00
Krystian Kuzniarek
6e87238c9b remove BiggestInt 2019-10-24 08:31:26 +02:00