Boost.Test 吐出垃圾而不是可读的错误消息
我正在使用 Boost.Test 但测试失败。这很有趣,但结果却很可怕。这是 Boost.Test 的输出:
$ zwja/Build/Products/Debug/test ;出口; < 运行 2 个测试用例... /Users/daknok/Desktop/libxxqlite/test/DatabaseTest.cpp:32:“P”中出现错误 `??k??k ???k?%??k??k 我 p??k???k?": *** 在测试套件“主测试套件”中检测到 1 个故障
这是我失败的测试用例:
BOOST_AUTO_TEST_CASE(Querying) {
BOOST_CHECK_NO_THROW({
XXQLite::Database db;
XXQLite::Query query1 = db.createQuery("CREATE TABLE Foo (Id PRIMARY KEY)");
XXQLite::Query query2
= db.createQuery("SELECT * FROM Foo WHERE Id=? OR Id=? OR Id=?",
1, 2, 3);
});
}
我真的不知道这里发生了什么。这些奇怪的、不可读的错误消息可能是什么原因造成的? Boost 不喜欢我的代码吗?我的 Boost 安装有问题吗?
I am using Boost.Test and my test fails. That's fun and all, but the results are horrifying. This is the output of Boost.Test:
$ zwja/Build/Products/Debug/test ; exit; < Running 2 test cases... /Users/daknok/Desktop/libxxqlite/test/DatabaseTest.cpp:32: error in "P `??k??k ???k?%??k??k l p??k????k?": *** 1 failure detected in test suite "Master Test Suite"
Here is my failing test case:
BOOST_AUTO_TEST_CASE(Querying) {
BOOST_CHECK_NO_THROW({
XXQLite::Database db;
XXQLite::Query query1 = db.createQuery("CREATE TABLE Foo (Id PRIMARY KEY)");
XXQLite::Query query2
= db.createQuery("SELECT * FROM Foo WHERE Id=? OR Id=? OR Id=?",
1, 2, 3);
});
}
I really have no idea what's going on here. What could be the cause of these strange, unreadable error messages? Did Boost not like my code? Is there something wrong with my Boost installation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据此处的示例,问号之间的内容是您传递给
BOOST_AUTO_TEST_CASE
的内容:输出:
也就是说,对于您来说,它应该打印
“查询”
。这个名字有什么来头吗?如果改成别的东西还能用吗?另请尝试查看预处理器输出。如果您使用的是 gcc,请使用
-E
标志。According to the example here, the thing between the question marks is what you passed to
BOOST_AUTO_TEST_CASE
:Output:
That is, for you it should print
"Querying"
. Anything going on with that name? Does it work if you change it to something else?Also try looking at your preprocessor output. If you're using gcc, use the
-E
flag.看来你有某种内存损坏。进行干净的构建。尝试 valgrind。尝试不同的升压释放。
It appears you have some kind of memory corruption. Do a clean build. Try valgrind. Try different boost release.
首先,您的代码并不能完全帮助您找到哪个调用正在抛出异常或通常会给您带来悲伤。因此,我建议您使用类似“那样”的方法
,这样您就能更好地找出确切是什么语句导致了问题。它可以是声明之一,例如
Database db
、Query query1
。它可能是 db.createQuery 调用之一。Firstly your code doesn't quite help you find which of the calls is throwing an exception or generally giving you grief. So I'd suggest instead something like
That way you'll have better luck finding out exactly what statement caused problems. It could be one of the declarations e.g.
Database db
,Query query1
. It could be one of the callsdb.createQuery
.