- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在编译和运行以下文件后运行可执行文件时出现上述错误。
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/bind.hpp>
#include <boost/test/unit_test_log.hpp>
#include <boost/filesystem/fstream.hpp>
#include "index/DatabaseGroup.hpp"
using namespace boost::unit_test;
namespace indexing {
class ForwardDBTest {
/// A pointer to the database group object.
DatabaseGroup& databaseGroup;
std::string databaseName;
public:
~ForwardDBTest() {
}
;
ForwardDBTest(DatabaseGroup& databaseGroup_, std::string dbName) :
databaseGroup(databaseGroup_), databaseName(dbName) {
}
void boostTestCreateDB() {
databaseGroup.createDatabase(databaseName, databaseName);
}
};
class testSuites: public test_suite {
public:
testSuites() :
test_suite("test_suite") {
std::string db_location = "home/girijag/ripe/ripe_db";
std::cout << "hello" << std::endl;
int concurrency = 0;
std::string db_cache_policy = "AllMem";
boost::shared_ptr<DatabaseGroup> db = boost::shared_ptr<DatabaseGroup>(
new DatabaseGroup(db_location, concurrency, db_cache_policy));
std::string dbName = "DB1";
boost::shared_ptr<ForwardDBTest> instance(
new ForwardDBTest(*db, dbName));
test_case* boostTestCreateDB_test_case = BOOST_CLASS_TEST_CASE(
&ForwardDBTest::boostTestCreateDB, instance);
add(boostTestCreateDB_test_case);
}
~testSuites() {
}
;
};
test_suite* init_unit_test_suite(int argc, char** argv) {
test_suite* suite(BOOST_TEST_SUITE("Master Suite"));
suite->add(new testSuites());
return suite;
}
}'
请让我知道我应该如何解决这个问题?我收到如下错误:-
Test setup error: memory access violation at address: 0x00000021: no mapping at fault address
过去两天我一直在努力弄清楚我的问题是什么
最佳答案
代码中有很多令人不安的东西,发布问题时似乎必须丢失一些格式,否则就没有编译的机会。 (例如,}’
?!)
对于初学者,您不应该将 init_unit_test_suite(int, char**)
放在 indexing 命名空间中,随后定义 BOOST_TEST_MAIN 也没有意义
- 您最终会得到上述 init_unit_test_suite(int, char**)
方法的多个定义。
在您的情况下,套件应该简单地在主测试套件中注册,无需从方法返回指向它的指针。
这是一个最小的示例,您可以根据自己的目的使用扩展。它遵循您的结构,但省略了不相关的细节:
#include <boost/test/included/unit_test.hpp>
#include <iostream>
using namespace boost::unit_test;
namespace indexing {
class ForwardDBTest {
public:
void boostTestCreateDB() { std::cout << __FUNCTION__ << std::endl; }
};
class TestSuite : public test_suite {
public:
TestSuite() : test_suite("test_suite") {
boost::shared_ptr<ForwardDBTest> instance(new ForwardDBTest);
add(BOOST_CLASS_TEST_CASE(&ForwardDBTest::boostTestCreateDB, instance));
}
};
} // namespace indexing
test_suite* init_unit_test_suite(int, char**) {
framework::master_test_suite().add(new indexing::TestSuite);
return 0;
}
/* Output:
Running 1 test case...
boostTestCreateDB
*** No errors detected
*/
关于c++ - Boost 测试设置错误 : memory access violation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21934179/
我正在为学校做作业。该代码应该从文件中读取并创建一个数组,然后对数组的值进行排序以输出某些信息。只要我在文件中有 3 行以上的信息,它就可以正常工作。如果没有,我会收到以下错误: First-chan
在我的表中,我有一个唯一的约束。在 hibernate 中,当我添加一个违反该约束的项目时,我想捕获它,因此它将更新而不是创建一个项目。 当我没有设置 try-catch block 时 up
我正在尝试将 Excel 文件中的一些数据插入到表中。我有两个excel文件如下: Test2: 5/12/2012 5/18/2012 ABQ ANC 1 52 5/12/2012
我有自定义约束: @Target({FIELD, METHOD}) @Retention(RetentionPolicy.RUNTIME) @ConstraintComposition(Composi
“违反任何时间序列”和“违反所有时间序列”这两个选项有什么区别?我可以想象前者会轻松做什么,但我不知道后者会做什么。 所有时间序列?它的射程有多长?为什么它有一个 for 选项? 最佳答案 What'
我正在尝试初始化 DataEditor 的对象,我的DataEditor类(class)工具interface IDataEditor where T : IEditableObject . Data
我正在使用带有 java 插件 4.0 和 findbugs 插件 3.4.3 的 SonarQube 5.6。使用此配置,findbugs 报告的外部类违规不会被报告为 Sonar 违规。以下是代码
我正在使用 DbUnit 框架对我的 JPA 实体 bean 进行单元测试。我已经从数据库表生成了实体。还将 DB 数据导出到 xml 文件中,DbUnit 在执行测试时可以使用这些文件。 但是对于每
我写了这段简单的代码来动态分配一个 4 维数组: #include #include int**** alloc() { int i,j,k; int ****matrix;
我的 Java 程序出现问题。我使用 MS Access 作为数据库,并使用 UCanAccess 连接到数据库。 当我尝试将文本插入数据库时,出现异常: net.ucanaccess.jdbc.
我正在尝试使用埃拉托斯特尼筛法解决 SPOJ 的 PRIME1 问题。该代码对于较小的整数工作正常,但对于长整数显示以下错误 - "Unhandled exception at 0x770d15ee
我不明白这个案例,但这对我来说真的很重要,请帮助我... void __fastcall TForm1::Button4Click(TObject *Sender) { String masu
请看我的代码: adj = (int *)calloc(n * n, sizeof(int)); scanf("%d", &m); for (i = 0; i < m; i++) { scan
下面这段代码有什么问题以及如何修复它。 #include using namespace std; template class guard{ public: guard(Func1 firs
我有一个多线程 C# 应用程序,它创建文件,打开它们进行处理,然后在完成后删除它们。此应用程序可以预期处理 1 - 100 个文件。有点随机(很可能归因于应用程序的多线程性质)当我尝试在处理后删除文件
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 8 年前。 Improve t
是否有可能在出现段错误后恢复 C 程序的正常执行流程? struct A { int x; }; A* a = 0; a->x = 123; // this is where segmenta
在 Magento 中使用信用卡/借记卡下订单时出现以下错误: Order saving error: SQLSTATE[23000]: Integrity constraint violation:
我正在处理属于 SDK 一部分的文件。当我在 phpstorm 中将文件提交到 svn 时,我收到关于 Unused definition SomeFunction 的警告,其中 SomeFuncti
简而言之,我有一个 C# 应用程序执行大量 mciSendString 调用(通过 dllimport)来控制 wav 文件播放(本质上是打开、播放、暂停、停止、状态、关闭)。运行一段时间后,应用程序
我是一名优秀的程序员,十分优秀!