Example #1
0
        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") );

        }
Example #2
0
 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() ); 
     }
 }