From aa486f165e982e82e2112d20a7561f64736d4b42 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 8 Nov 2021 13:49:32 -0500 Subject: [PATCH] Googletest export Add missing InitGoogleTest line in "Registering tests" example code Copying the original code gives the following error message """ IMPORTANT NOTICE - DO NOT IGNORE: This test program did NOT call testing::InitGoogleTest() before calling RUN_ALL_TESTS(). This is INVALID. Soon Google Test will start to enforce the valid usage. Please fix it ASAP, or IT WILL START TO FAIL. """ PiperOrigin-RevId: 408385714 --- docs/advanced.md | 1 + googletest/include/gtest/gtest.h | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/advanced.md b/docs/advanced.md index 71148572..f2f8854b 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -1597,6 +1597,7 @@ void RegisterMyTests(const std::vector& values) { } ... int main(int argc, char** argv) { + testing::InitGoogleTest(&argc, argv); std::vector values_to_test = LoadValuesFromConfig(); RegisterMyTests(values_to_test); ... diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index cdde1aa4..1bb9decc 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -2451,6 +2451,7 @@ GTEST_API_ std::string TempDir(); // } // ... // int main(int argc, char** argv) { +// ::testing::InitGoogleTest(&argc, argv); // std::vector values_to_test = LoadValuesFromConfig(); // RegisterMyTests(values_to_test); // ...