summaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorChris <chrisjohnsonmail@gmail.com>2019-01-03 18:12:19 (GMT)
committerChris <chrisjohnsonmail@gmail.com>2019-01-03 18:12:19 (GMT)
commit4d62b5b9aef027a8c4f4432ecc661de0b87b4f46 (patch)
tree5a94250423b6624e9a5782547c0f2fa48ce80d8a /googlemock
parentde99386b67a32a955c7b6215c4b2a50066dfa6a3 (diff)
downloadgoogletest-4d62b5b9aef027a8c4f4432ecc661de0b87b4f46.zip
googletest-4d62b5b9aef027a8c4f4432ecc661de0b87b4f46.tar.gz
googletest-4d62b5b9aef027a8c4f4432ecc661de0b87b4f46.tar.bz2
fix: Remove Arduino entry points
Improved flexibility by removing the Arduino entry points in favor of manual calls to setup/loop that the user can call from their entry point. This is the more common use case for Arudino. Also added the gtest/gmock_main files to the PlatformIO ignore list since we are not supporting that feature.
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/include/gmock/gmock.h16
-rw-r--r--googlemock/src/gmock_main.cc17
2 files changed, 16 insertions, 17 deletions
diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h
index a1e1e6f..14ad551 100644
--- a/googlemock/include/gmock/gmock.h
+++ b/googlemock/include/gmock/gmock.h
@@ -92,6 +92,22 @@ GTEST_API_ void InitGoogleMock(int* argc, char** argv);
// UNICODE mode.
GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv);
+#ifdef ARDUINO
+inline void gmock_setup() {
+ // Since Arduino doesn't have a command line, fake out the argc/argv arguments
+ int argc = 1;
+ const auto arg0 = "PlatformIO";
+ char* argv0 = const_cast<char*>(arg0);
+ char** argv = &argv0;
+
+ // Since Google Mock depends on Google Test, InitGoogleMock() is
+ // also responsible for initializing Google Test. Therefore there's
+ // no need for calling testing::InitGoogleTest() separately.
+ testing::InitGoogleMock(&argc, argv);
+}
+inline void gmock_loop() { RUN_ALL_TESTS(); }
+#endif
+
} // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_
diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc
index db35bc3..a3a271e 100644
--- a/googlemock/src/gmock_main.cc
+++ b/googlemock/src/gmock_main.cc
@@ -32,22 +32,6 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#ifdef ARDUINO
-void setup() {
- // Since Arduino doesn't have a command line, fake out the argc/argv arguments
- int argc = 1;
- const auto arg0 = "PlatformIO";
- char* argv0 = const_cast<char*>(arg0);
- char** argv = &argv0;
-
- // Since Google Mock depends on Google Test, InitGoogleMock() is
- // also responsible for initializing Google Test. Therefore there's
- // no need for calling testing::InitGoogleTest() separately.
- testing::InitGoogleMock(&argc, argv);
-}
-void loop() { RUN_ALL_TESTS(); }
-#else
-
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
// causes a link error when _tmain is defined in a static library and UNICODE
// is enabled. For this reason instead of _tmain, main function is used on
@@ -68,4 +52,3 @@ GTEST_API_ int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
-#endif