何らかの理由で、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
私はGoogleのテスト入門を読んでも、彼らの使用例を見てEXPECT_STREQをgoogletestコードベースで使用し、間違った考えを得ました。それをクリアしていただきありがとうございます。 –