diff options
Diffstat (limited to 'googlemock/src')
-rw-r--r-- | googlemock/src/gmock.cc | 12 | ||||
-rw-r--r-- | googlemock/src/gmock_main.cc | 5 |
2 files changed, 13 insertions, 4 deletions
diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc index 3fd2e93..05566e2 100644 --- a/googlemock/src/gmock.cc +++ b/googlemock/src/gmock.cc @@ -198,4 +198,16 @@ GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv) { internal::InitGoogleMockImpl(argc, argv); } +// This overloaded version can be used on Arduino/embedded platforms where +// there is no argc/argv. +GTEST_API_ void InitGoogleMock() { + // Since Arduino doesn't have a command line, fake out the argc/argv arguments + int argc = 1; + const auto arg0 = "dummy"; + char* argv0 = const_cast<char*>(arg0); + char** argv = &argv0; + + internal::InitGoogleMockImpl(&argc, argv); +} + } // namespace testing diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc index 3306ffc..98611b9 100644 --- a/googlemock/src/gmock_main.cc +++ b/googlemock/src/gmock_main.cc @@ -34,12 +34,10 @@ #ifdef ARDUINO void setup() { - int argc = 0; - char** argv = nullptr; // 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); + testing::InitGoogleMock(); } void loop() { RUN_ALL_TESTS(); } #else @@ -64,5 +62,4 @@ GTEST_API_ int main(int argc, char** argv) { testing::InitGoogleMock(&argc, argv); return RUN_ALL_TESTS(); } - #endif |