本文整理汇总了C++中MultiTag::removeReference方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiTag::removeReference方法的具体用法?C++ MultiTag::removeReference怎么用?C++ MultiTag::removeReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiTag
的用法示例。
在下文中一共展示了MultiTag::removeReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testReferences
void BaseTestMultiTag::testReferences(){
DataArray da_1 = block.createDataArray("TestReference 1",
"Reference",
DataType::Double,
NDSize({ 0 }));
DataArray da_2 = block.createDataArray("TestReference 2", "Reference",
DataType::Double,
NDSize({ 0 }));
DataArray a;
MultiTag dt = block.createMultiTag("TestMultiTag1", "Tag", positions);
CPPUNIT_ASSERT_THROW(dt.getReference(42), OutOfBounds);
CPPUNIT_ASSERT(!dt.hasReference(a));
std::stringstream counterrmsg;
counterrmsg << "BaseTestMultiTag::testReference: Counts do not match!";
CPPUNIT_ASSERT_MESSAGE(counterrmsg.str(), dt.referenceCount() == 0);
dt.addReference(da_1);
dt.addReference(da_2);
CPPUNIT_ASSERT_THROW(dt.addReference(a), UninitializedEntity);
CPPUNIT_ASSERT_THROW(dt.removeReference(a), UninitializedEntity);
CPPUNIT_ASSERT_MESSAGE(counterrmsg.str(), dt.referenceCount() == 2);
CPPUNIT_ASSERT(dt.hasReference(da_1));
CPPUNIT_ASSERT(dt.hasReference(da_2));
std::stringstream haserrmsg;
haserrmsg << "BaseTestMultiTag::testReference: Has method did not work!";
CPPUNIT_ASSERT_MESSAGE(haserrmsg.str(), dt.hasReference(da_1.id()));
CPPUNIT_ASSERT_MESSAGE(haserrmsg.str(), dt.hasReference(da_1.name()));
DataArray ref1 = dt.getReference(da_1.id());
std::stringstream retrieveerrmsg;
retrieveerrmsg << "BaseTestMultiTag::testReference: Retrieval did not work!";
CPPUNIT_ASSERT_MESSAGE(retrieveerrmsg.str(), ref1.id() == da_1.id());
DataArray ref2 = dt.getReference(da_1.name());
retrieveerrmsg << "BaseTestMultiTag::testReference: Retrieval by name did not work!";
CPPUNIT_ASSERT_MESSAGE(retrieveerrmsg.str(), ref2.id() == da_1.id());
std::vector<DataArray> arrays = dt.references();
CPPUNIT_ASSERT_MESSAGE(retrieveerrmsg.str(), arrays.size() == 2);
std::stringstream hasReferrmsg;
hasReferrmsg << "BaseTestMultiTag::testReference: hadReference did not work!";
CPPUNIT_ASSERT_MESSAGE(hasReferrmsg.str(), dt.hasReference(da_1.id()));
CPPUNIT_ASSERT_MESSAGE(hasReferrmsg.str(), dt.hasReference(da_2.id()));
std::stringstream delReferrmsg;
delReferrmsg << "BaseTestMultiTag::testReference: removeReference did not work!";
dt.removeReference(da_1.id());
CPPUNIT_ASSERT_MESSAGE(delReferrmsg.str(), dt.referenceCount() == 1);
dt.removeReference("NONEXISTENT");
CPPUNIT_ASSERT_MESSAGE(delReferrmsg.str(), dt.referenceCount() == 1);
dt.removeReference(da_2.name());
CPPUNIT_ASSERT_MESSAGE(delReferrmsg.str(), dt.referenceCount() == 0);
dt.addReference(da_1);
CPPUNIT_ASSERT(dt.referenceCount() == 1);
CPPUNIT_ASSERT_NO_THROW(dt.removeReference(da_1));
CPPUNIT_ASSERT(dt.referenceCount() == 0);
// delete data arrays
std::vector<std::string> ids = {da_1.id(), da_2.id()};
block.deleteDataArray(da_1.id());
block.deleteDataArray(da_2.id());
// check if references are gone too!
CPPUNIT_ASSERT(dt.referenceCount() == 0);
CPPUNIT_ASSERT(!dt.hasReference(ids[0]));
CPPUNIT_ASSERT(!dt.hasReference(ids[1]));
block.deleteMultiTag(dt.id());
}