//======================================================================================= // ModelBuilder implementation //======================================================================================= ImoDocument* ModelBuilder::build_model(InternalModel* IModel) { ImoDocument* pDoc = static_cast<ImoDocument*>( IModel->get_root() ); if (pDoc) { VisitorForStructurizables v(this); pDoc->accept_visitor(v); } return pDoc; }
TEST_FIXTURE(ImVisitorTestFixture, ParagraphHeadingVisitor) { Document doc(m_libraryScope); doc.from_file(m_scores_path + "09002-ebook-example.lms" ); ImoDocument* pRoot = doc.get_im_root(); MyHPVisitor v(m_libraryScope); pRoot->accept_visitor(v); // cout << "max_depth=" << v.max_depth() // << ", num_in_nodes=" << v.num_in_nodes() // << ", num_out_nodes=" << v.num_out_nodes() << endl; CHECK( v.max_depth() == 1 ); CHECK( v.num_in_nodes() == 6 ); CHECK( v.num_out_nodes() == v.num_in_nodes() ); }
TEST_FIXTURE(ImVisitorTestFixture, Document) { Document doc(m_libraryScope); doc.from_string("(lenmusdoc (vers 2.3) (content))" ); ImoDocument* pRoot = doc.get_im_root(); MyObjVisitor v(m_libraryScope); pRoot->accept_visitor(v); // cout << "max_depth=" << v.max_depth() // << ", num_in_nodes=" << v.num_in_nodes() // << ", num_out_nodes=" << v.num_out_nodes() << endl; CHECK( v.max_depth() == 3 ); CHECK( v.num_in_nodes() == 12 ); CHECK( v.num_out_nodes() == v.num_in_nodes() ); }