2012-04-27 47 views
0

我已將項目轉換爲VS2010。它包含一個基於googletest的單元測試項目。當我用宏EXPECT_EQ,我得到下面的連接錯誤:googletest和VS2010:無法使用EXPECT_EQ

LNK2019: unresolved external symbol "class testing::internal::String __cdecl testing::internal::StrStreamToString(class std::basic_stringstream,class std::allocator > *)" ([email protected]@[email protected]@YA? [email protected]@[email protected][email protected]@[email protected]@V? [email protected]@[email protected]@[email protected]@@Z) referenced in function "public: class testing::internal::String __thiscall testing::Message::GetString(void)const " (? [email protected]@[email protected]@[email protected]@[email protected])

當我使用EXPECT_TRUE,一切工作正常。有人知道這個問題嗎?

謝謝

+0

您能給出您的EXPECT_EQ語句的代碼示例嗎? – 2012-05-06 13:31:13

回答

1

EXPECT_EQ嘗試將您的數據值轉換爲字符串以進行顯示; EXPECT_TRUE不。

沒有看到您的代碼,它會顯示您正在測試可以編譯該功能但未鏈接的用戶類型,即未實現。

這是一個常見問題。如果EXPECT_TRUE有效,你可能只想堅持下去。

+0

這只是我幾個小時。我有一個模板專門化:'template struct is_thing { static const bool value = false; }; template <> struct is_thing { static const bool value = true; };'然後我試着做'EXPECT_EQ(is_thing :: value,false);'並且得到鏈接器錯誤。 'EXPECT_FALSE(is_thing :: value);'按你的建議正常工作。你能解釋一下更多的區別是什麼/爲什麼會發生這種情況? – 2016-02-08 20:12:39

+0

@DavidDoria:問一個適當的問題併發布相關代碼真的會更好。從評論鏈接到它,如果你喜歡。 – 2016-02-09 07:08:57