由于某种原因,GTest在我的开发站上做得不太好。一些ASSERT/EXPECT测试正在工作,但我无法让字符串比较工作。这就是代码在CLion中的样子;注意到错误酥料饼:Windows GTest EXPECT_STREQ:错误:没有匹配函数调用'CmpHelperSTREQ'
另外附接在底部是在编译时的错误输出。由于我在Windows 10上使用JetBrains CLion,GTest必须使用“MinGW Makefiles”CMake生成器,然后使用MinGW make(而不是使用CMake默认的Visual Studio生成器)来构建。此外,我能找到的唯一工作源是最新的Github GTest主分支;它在2016年11月的最新版本将不会在MinGW的Windows上构建。
In file included from C:/PROGRA~2/GOOGLE~1/include/gtest/gtest.h:1874:0,
from C:\projects\gtest-test\tests\basic_test.cpp:4:
C:\projects\gtest-test\tests\basic_test.cpp: In member function 'virtual void basic_test_helloWorldEqualsHelloWorld_Test::TestBody()':
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest_pred_impl.h:147:45: error: no matching function for call to 'CmpHelperSTREQ(const char [7], const char [7], std::__cxx11::string&, std::__cxx11::string&)'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
^
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest_pred_impl.h:77:52: note: in definition of macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest_pred_impl.h:162:3: note: in expansion of macro 'GTEST_PRED_FORMAT2_'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
^
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest.h:1996:3: note: in expansion of macro 'EXPECT_PRED_FORMAT2'
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
^
C:\projects\gtest-test\tests\basic_test.cpp:14:5: note: in expansion of macro 'EXPECT_STREQ'
EXPECT_STREQ(hello2, hello3);
^
In file included from C:\projects\gtest-test\tests\basic_test.cpp:4:0:
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest.h:1537:28: note: candidate: testing::AssertionResult testing::internal::CmpHelperSTREQ(const char*, const char*, const char*, const char*)
GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
^
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest.h:1537:28: note: no known conversion for argument 3 from 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'const char*'
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest.h:1570:28: note: candidate: testing::AssertionResult testing::internal::CmpHelperSTREQ(const char*, const char*, const wchar_t*, const wchar_t*)
GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
^
C:/PROGRA~2/GOOGLE~1/include/gtest/gtest.h:1570:28: note: no known conversion for argument 3 from 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'const wchar_t*'
tests\CMakeFiles\gtestTest_tests.dir\build.make:62: recipe for target 'tests/CMakeFiles/gtestTest_tests.dir/basic_test.cpp.obj' failed
mingw32-make.exe[3]: *** [tests/CMakeFiles/gtestTest_tests.dir/basic_test.cpp.obj] Error 1
mingw32-make.exe[2]: *** [tests/CMakeFiles/gtestTest_tests.dir/all] Error 2
CMakeFiles\Makefile2:1063: recipe for target 'tests/CMakeFiles/gtestTest_tests.dir/all' failed
mingw32-make.exe[1]: *** [tests/CMakeFiles/gtestTest_tests.dir/rule] Error 2
CMakeFiles\Makefile2:1075: recipe for target 'tests/CMakeFiles/gtestTest_tests.dir/rule' failed
Makefile:494: recipe for target 'gtestTest_tests' failed
mingw32-make.exe: *** [gtestTest_tests] Error 2
我读谷歌测试底漆,甚至看着他们的使用示例EXPORT_STREQ在googletest代码库中,并得到了错误的想法。感谢您清理它。 –