本文整理汇总了C++中Alloc::setMC方法的典型用法代码示例。如果您正苦于以下问题:C++ Alloc::setMC方法的具体用法?C++ Alloc::setMC怎么用?C++ Alloc::setMC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alloc
的用法示例。
在下文中一共展示了Alloc::setMC方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tlist
void
TC_MemFail03::run()
{
MemoryControlWithFailure mc;
mc.resetCounters();
mc.disableLimit();
Alloc<REToken *> alloc;
alloc.setMC(&mc);
{
TokenList tlist(&mc, alloc, "[a-z]");
}
size_t numAllocs = mc.m_numAllocs;
for (size_t lim = 0; lim < numAllocs; lim++) {
mc.resetCounters();
mc.setLimit(lim);
try {
TokenList tlist(&mc, alloc, "[a-z]");
ASSERT_TRUE(false);
}
catch (const bad_alloc &e) {
ASSERT_TRUE(true);
}
}
this->setStatus(true);
}
示例2: new
void
TC_Basic02::run()
{
MemoryControl mc;
Alloc<REToken *> alloc;
alloc.setMC(&mc);
TokenList *toks = new (&mc) TokenList(&mc, alloc, "");
toks->~TokenList();
mc.deallocate(toks, 1);
this->setStatus(true);
}
示例3:
void
TC_MemFail2_05::run()
{
MemoryControlWithFailure mc;
mc.resetCounters();
mc.disableLimit();
Alloc<REToken *> alloc;
alloc.setMC(&mc);
this->expectFailure(mc, alloc, "{2 2}");
this->expectFailure(mc, alloc, "{2 - }");
this->expectFailure(mc, alloc, "{999999999999999999999999999999999");
this->expectFailure(mc, alloc, "a{2,99999999999999999999999999999999999}");
this->setStatus(true);
}
示例4: catch
void
TC_Postfix_MemFail_01::run()
{
MemoryControlWithFailure mc;
mc.resetCounters();
mc.disableLimit();
Alloc<REToken *> alloc;
alloc.setMC(&mc);
{
TokenList2 tlist1(&mc, alloc);
TokenList2 tlist2(&mc, alloc);
TokenList2::tmpTokList tmpList;
tlist1.build("a");
tlist2.buildPostfix(&tlist1, &tmpList);
}
size_t numAllocs = mc.m_numAllocs;
for (size_t lim = 0; lim < numAllocs; lim++) {
mc.resetCounters();
mc.setLimit(lim);
try {
TokenList2 tlist1(&mc, alloc);
tlist1.build("a");
TokenList2 tlist2(&mc, alloc);
TokenList2::tmpTokList tmpList;
tlist2.buildPostfix(&tlist1, &tmpList);
ASSERT_TRUE(false);
}
catch (const bad_alloc &e) {
ASSERT_TRUE(true);
}
}
this->setStatus(true);
}