本文整理汇总了C++中NodeRef::get_name方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRef::get_name方法的具体用法?C++ NodeRef::get_name怎么用?C++ NodeRef::get_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeRef
的用法示例。
在下文中一共展示了NodeRef::get_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testValidName
void testValidName() {
try {
NodeRef di = Terminal::create("test 1" ); // space in name
CPPUNIT_FAIL ( "invalid name creation didn't throw." );
} catch ( const Exception &e ) {
CPPUNIT_ASSERT_EQUAL ( Nitro::NODE_NAME_ERROR, (NITRO_ERROR)e.code() );
}
NodeRef di = Terminal::create("valid_name");
CPPUNIT_ASSERT_THROW ( di->set_name(" invalid name"), Exception );
CPPUNIT_ASSERT_THROW ( di->set_name("1invalid_name"), Exception );
CPPUNIT_ASSERT_THROW ( di->set_name("invalid&name"), Exception );
CPPUNIT_ASSERT_EQUAL ( std::string ( "valid_name" ), di->get_name() );
CPPUNIT_ASSERT_NO_THROW ( di->set_name("something_else_valid") );
}
示例2: testOrder
void testOrder() {
NodeRef orig = DeviceInterface::create("top");
for (int i=10;i>=0;--i) {
std::stringstream io;
std::string name;
io << '_';
io << i;
io >> name;
NodeRef child = Terminal::create(name);
orig->add_child(child);
}
// nodes are ordered
int i=10;
for (DITreeIter itr=orig->child_begin();itr!=orig->child_end();++itr) {
NodeRef c =*itr;
std::stringstream io;
std::string name;
io << '_';
io << i--;
io >> name;
CPPUNIT_ASSERT_EQUAL ( name, c->get_name() );
}
}