xref: /freebsd/contrib/googletest/googlemock/src/gmock_main.cc (revision 28f6c2f292806bf31230a959bc4b19d7081669a7)
1b89a7cc2SEnji Cooper // Copyright 2008, Google Inc.
2b89a7cc2SEnji Cooper // All rights reserved.
3b89a7cc2SEnji Cooper //
4b89a7cc2SEnji Cooper // Redistribution and use in source and binary forms, with or without
5b89a7cc2SEnji Cooper // modification, are permitted provided that the following conditions are
6b89a7cc2SEnji Cooper // met:
7b89a7cc2SEnji Cooper //
8b89a7cc2SEnji Cooper //     * Redistributions of source code must retain the above copyright
9b89a7cc2SEnji Cooper // notice, this list of conditions and the following disclaimer.
10b89a7cc2SEnji Cooper //     * Redistributions in binary form must reproduce the above
11b89a7cc2SEnji Cooper // copyright notice, this list of conditions and the following disclaimer
12b89a7cc2SEnji Cooper // in the documentation and/or other materials provided with the
13b89a7cc2SEnji Cooper // distribution.
14b89a7cc2SEnji Cooper //     * Neither the name of Google Inc. nor the names of its
15b89a7cc2SEnji Cooper // contributors may be used to endorse or promote products derived from
16b89a7cc2SEnji Cooper // this software without specific prior written permission.
17b89a7cc2SEnji Cooper //
18b89a7cc2SEnji Cooper // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19b89a7cc2SEnji Cooper // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20b89a7cc2SEnji Cooper // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21b89a7cc2SEnji Cooper // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22b89a7cc2SEnji Cooper // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23b89a7cc2SEnji Cooper // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24b89a7cc2SEnji Cooper // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25b89a7cc2SEnji Cooper // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26b89a7cc2SEnji Cooper // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27b89a7cc2SEnji Cooper // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28b89a7cc2SEnji Cooper // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29b89a7cc2SEnji Cooper 
30b89a7cc2SEnji Cooper #include <iostream>
31*28f6c2f2SEnji Cooper 
32b89a7cc2SEnji Cooper #include "gmock/gmock.h"
33b89a7cc2SEnji Cooper #include "gtest/gtest.h"
34b89a7cc2SEnji Cooper 
35*28f6c2f2SEnji Cooper #if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) || \
36*28f6c2f2SEnji Cooper     (defined(GTEST_OS_NRF52) && defined(ARDUINO))
37*28f6c2f2SEnji Cooper #ifdef GTEST_OS_ESP8266
38*28f6c2f2SEnji Cooper extern "C" {
39*28f6c2f2SEnji Cooper #endif
setup()40*28f6c2f2SEnji Cooper void setup() {
41*28f6c2f2SEnji Cooper   // Since Google Mock depends on Google Test, InitGoogleMock() is
42*28f6c2f2SEnji Cooper   // also responsible for initializing Google Test.  Therefore there's
43*28f6c2f2SEnji Cooper   // no need for calling testing::InitGoogleTest() separately.
44*28f6c2f2SEnji Cooper   testing::InitGoogleMock();
45*28f6c2f2SEnji Cooper }
loop()46*28f6c2f2SEnji Cooper void loop() { RUN_ALL_TESTS(); }
47*28f6c2f2SEnji Cooper #ifdef GTEST_OS_ESP8266
48*28f6c2f2SEnji Cooper }
49*28f6c2f2SEnji Cooper #endif
50*28f6c2f2SEnji Cooper 
51*28f6c2f2SEnji Cooper #else
52*28f6c2f2SEnji Cooper 
53b89a7cc2SEnji Cooper // MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
54b89a7cc2SEnji Cooper // causes a link error when _tmain is defined in a static library and UNICODE
55b89a7cc2SEnji Cooper // is enabled. For this reason instead of _tmain, main function is used on
56b89a7cc2SEnji Cooper // Windows. See the following link to track the current status of this bug:
57b89a7cc2SEnji Cooper // https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
58b89a7cc2SEnji Cooper // // NOLINT
59*28f6c2f2SEnji Cooper #ifdef GTEST_OS_WINDOWS_MOBILE
60b89a7cc2SEnji Cooper #include <tchar.h>  // NOLINT
61b89a7cc2SEnji Cooper 
_tmain(int argc,TCHAR ** argv)62b89a7cc2SEnji Cooper GTEST_API_ int _tmain(int argc, TCHAR** argv) {
63b89a7cc2SEnji Cooper #else
64b89a7cc2SEnji Cooper GTEST_API_ int main(int argc, char** argv) {
65b89a7cc2SEnji Cooper #endif  // GTEST_OS_WINDOWS_MOBILE
66b89a7cc2SEnji Cooper   std::cout << "Running main() from gmock_main.cc\n";
67b89a7cc2SEnji Cooper   // Since Google Mock depends on Google Test, InitGoogleMock() is
68b89a7cc2SEnji Cooper   // also responsible for initializing Google Test.  Therefore there's
69b89a7cc2SEnji Cooper   // no need for calling testing::InitGoogleTest() separately.
70b89a7cc2SEnji Cooper   testing::InitGoogleMock(&argc, argv);
71b89a7cc2SEnji Cooper   return RUN_ALL_TESTS();
72b89a7cc2SEnji Cooper }
73*28f6c2f2SEnji Cooper #endif
74