0
我有一個比較兩個字符串值的QtTest:QtTest失敗,即使他們是相同的? C++
// This definitely returns "5/6"
std::string actual_value = simple(actual);
// Sets a string to the expected value
std::string expected_value = "5/6";
然後QCOMPARE:
QCOMPARE(QString(actual_value.c_str()), QString(expected_value.c_str()));
/* I'm Aware this could just be the code below (but this doesnt print values to
console so i can check they are actually the same) */
QCOMPARE(actual_value, expected_value)
,我得到的錯誤:(生病後都因此其明顯的不只是事QString的失敗,所以下面使用的QString顯示值)
FAIL! : TestFraction::testFraction() Compared values are not the same
Actual (QString(actual_value.c_str())): 5/6
Expected (QString(expected_value.c_str())): 5/6
的QCOMPARE,這是正常QCOMPARE錯誤消息:
FAIL! : TestFraction::testFraction() Compared values are not the same
有後面這一點,但我不是現在公佈它,因爲我不認爲它特別相關,但問,如果有件事你要知道,據我可以看到這個測試應該通過,但也許那裏有明顯的其他代碼提前
那好吧,謝謝,所以生病必須看看有什麼即時試圖評估,然後......除非有比較這些 – AngryDuck
的一些方法看起來實際字符串有在最後一個新行字符。 –
OMG捂臉!是啊,多數民衆贊成如此明顯的權利,我不甚至需要表示感謝之前嘗試它,把它作爲一個答案和虐待接受 – AngryDuck