diff options
Diffstat (limited to 'googletest/src')
-rw-r--r-- | googletest/src/gtest.cc | 16 | ||||
-rw-r--r-- | googletest/src/gtest_main.cc | 8 |
2 files changed, 18 insertions, 6 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 23b6e5f..d1cfb53 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<char*>(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 92285a3..f6e1dd9 100644 --- a/googletest/src/gtest_main.cc +++ b/googletest/src/gtest_main.cc @@ -27,14 +27,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <stdio.h> +#include <cstdio> #include "gtest/gtest.h" #ifdef ARDUINO void setup() { - int argc = 0; - char** argv = nullptr; - testing::InitGoogleTest(&argc, argv); + testing::InitGoogleTest(); } void loop() { RUN_ALL_TESTS(); } @@ -46,6 +44,4 @@ GTEST_API_ int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } - #endif - |