0
我有一些简单的代码可以反转QString。QTestLib结果与程序输出不同
const QString reverse_qstring(const QString& str_in)
{
QString out;
Q_FOREACH(const QChar c, str_in) {
out.push_front(c);
}
return out;
}
当我从非ASCII字符的命令行中输入文本,事情会如预期:
"¿como estás?" : "?sátse omoc¿"
然而,当我提出以下的单元测试(使用QTestLib):
QCOMPARE(reverse_qstring(QString("¿como estás?")), QString("?sátse omoc¿"));
我得到:
FAIL! : program::test_qstring() Compared values are not the same
Actual (reverse_qstring(QString("??como est??s?"))): ?s??tse omoc??
Expected (QString("?s??tse omoc??")): ?s??tse omoc??
有什么想法?
小菜一碟!我希望unicode映射不是很多/不明显。 – taynaron 2013-03-03 02:34:44