diff --git a/.gitignore b/.gitignore index 3794794f..6209bf66 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,29 @@ googlemock/CTestTestfile.cmake googlemock/Makefile googlemock/cmake_install.cmake googlemock/gtest +/bin +/googlemock/gmock.dir +/googlemock/gmock_main.dir +/googlemock/RUN_TESTS.vcxproj.filters +/googlemock/RUN_TESTS.vcxproj +/googlemock/INSTALL.vcxproj.filters +/googlemock/INSTALL.vcxproj +/googlemock/gmock_main.vcxproj.filters +/googlemock/gmock_main.vcxproj +/googlemock/gmock.vcxproj.filters +/googlemock/gmock.vcxproj +/googlemock/gmock.sln +/googlemock/ALL_BUILD.vcxproj.filters +/googlemock/ALL_BUILD.vcxproj +/lib +/Win32 +/ZERO_CHECK.vcxproj.filters +/ZERO_CHECK.vcxproj +/RUN_TESTS.vcxproj.filters +/RUN_TESTS.vcxproj +/INSTALL.vcxproj.filters +/INSTALL.vcxproj +/googletest-distribution.sln +/CMakeCache.txt +/ALL_BUILD.vcxproj.filters +/ALL_BUILD.vcxproj diff --git a/.travis.yml b/.travis.yml index 3c52e78c..fd8f7c65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,9 +46,9 @@ matrix: env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON - os: osx compiler: gcc - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 - os: osx - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 if: type != pull_request # These are the install and build (script) phases for the most common entries in the matrix. They could be included diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h index c68ae1c7..7096984b 100644 --- a/googlemock/include/gmock/gmock.h +++ b/googlemock/include/gmock/gmock.h @@ -92,6 +92,10 @@ GTEST_API_ void InitGoogleMock(int* argc, char** argv); // UNICODE mode. GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv); +// This overloaded version can be used on Arduino/embedded platforms where +// there is no argc/argv. +GTEST_API_ void InitGoogleMock(); + } // namespace testing #endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_ diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc index 3fd2e939..05566e2d 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(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 db35bc37..98611b93 100644 --- a/googlemock/src/gmock_main.cc +++ b/googlemock/src/gmock_main.cc @@ -34,16 +34,10 @@ #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(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); + testing::InitGoogleMock(); } void loop() { RUN_ALL_TESTS(); } #else diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index bb547bc0..bcea1450 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -1484,6 +1484,10 @@ GTEST_API_ void InitGoogleTest(int* argc, char** argv); // UNICODE mode. GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv); +// This overloaded version can be used on Arduino/embedded platforms where +// there is no argc/argv. +GTEST_API_ void InitGoogleTest(); + namespace internal { // Separate the error generating code from the code path to reduce the stack diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 23b6e5f5..d1cfb535 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -6020,6 +6020,22 @@ void InitGoogleTest(int* argc, wchar_t** argv) { #endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) } +// This overloaded version can be used on Arduino/embedded platforms where +// there is no argc/argv. +void InitGoogleTest() { + // 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(arg0); + char** argv = &argv0; + +#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) + GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(&argc, argv); +#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) + internal::InitGoogleTestImpl(&argc, argv); +#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) +} + std::string TempDir() { #if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_) return GTEST_CUSTOM_TEMPDIR_FUNCTION_(); diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc index 5b94d603..f6e1dd96 100644 --- a/googletest/src/gtest_main.cc +++ b/googletest/src/gtest_main.cc @@ -32,13 +32,7 @@ #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(arg0); - char** argv = &argv0; - - testing::InitGoogleTest(&argc, argv); + testing::InitGoogleTest(); } void loop() { RUN_ALL_TESTS(); } diff --git a/library.json b/library.json index b662ee84..84c2b8c8 100644 --- a/library.json +++ b/library.json @@ -27,6 +27,7 @@ "googlemock/make", "googlemock/msvc", "googlemock/scripts", + "googlemock/src/gmock_main.cc", "googlemock/test", "googlemock/CMakeLists.txt", "googlemock/Makefile.am", @@ -37,6 +38,7 @@ "googletest/make", "googletest/msvc", "googletest/scripts", + "googletest/src/gtest_main.cc", "googletest/test", "googletest/xcode", "googletest/CMakeLists.txt",