diff options
author | Abseil Team <absl-team@google.com> | 2019-10-28 18:09:47 (GMT) |
---|---|---|
committer | vslashg <gfalcon@google.com> | 2019-10-29 20:51:40 (GMT) |
commit | 2bee6da24e9f63a22a4ed0f87e3db8583401fc68 (patch) | |
tree | 0afef7f51d87c1229538e136bba4e248d72aefc5 /googletest/docs/primer.md | |
parent | 755f853c6be9ff44d6125367fa5ebdb75c382640 (diff) | |
download | googletest-2bee6da24e9f63a22a4ed0f87e3db8583401fc68.zip googletest-2bee6da24e9f63a22a4ed0f87e3db8583401fc68.tar.gz googletest-2bee6da24e9f63a22a4ed0f87e3db8583401fc68.tar.bz2 |
Googletest export
Editorial cleanup of the "write the main function" section
PiperOrigin-RevId: 277102507
Diffstat (limited to 'googletest/docs/primer.md')
-rw-r--r-- | googletest/docs/primer.md | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/googletest/docs/primer.md b/googletest/docs/primer.md index 5139402..63f0516 100644 --- a/googletest/docs/primer.md +++ b/googletest/docs/primer.md @@ -491,15 +491,18 @@ You can start from this boilerplate: ```c++ #include "this/package/foo.h" + #include "gtest/gtest.h" +namespace my { +namespace project { namespace { // The fixture for testing class Foo. class FooTest : public ::testing::Test { protected: - // You can remove any or all of the following functions if its body - // is empty. + // You can remove any or all of the following functions if their bodies would + // be empty. FooTest() { // You can do set-up work for each test here. @@ -522,7 +525,8 @@ class FooTest : public ::testing::Test { // before the destructor). } - // Objects declared here can be used by all tests in the test suite for Foo. + // Class members declared here can be used by all tests in the test suite + // for Foo. }; // Tests that the Foo::Bar() method does Abc. @@ -539,6 +543,8 @@ TEST_F(FooTest, DoesXyz) { } } // namespace +} // namespace project +} // namespace my int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); @@ -555,10 +561,10 @@ the [AdvancedGuide](advanced.md). You **must** call this function before calling On Windows, `InitGoogleTest()` also works with wide strings, so it can be used in programs compiled in `UNICODE` mode as well. -But maybe you think that writing all those main() functions is too much work? We +But maybe you think that writing all those `main` functions is too much work? We agree with you completely, and that's why Google Test provides a basic implementation of main(). If it fits your needs, then just link your test with -gtest\_main library and you are good to go. +the `gtest_main` library and you are good to go. NOTE: `ParseGUnitFlags()` is deprecated in favor of `InitGoogleTest()`. |