Esempio n. 1
0
    TEST_FIXTURE(MxlCompilerTestFixture, MxlCompilerFromFile_100)
    {
        //100 - compile raw xml file format
        Document doc(m_libraryScope);
        MxlCompiler compiler(m_libraryScope, &doc);
        string path = m_scores_path + "50000-hello-world.xml";
        ImoObj* pRoot =  compiler.compile_file(path);
        CHECK( compiler.get_file_locator() == path );
        ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pRoot);
        CHECK( pDoc && pDoc->get_version() == "0.0" );
        CHECK( pDoc && pDoc->get_num_content_items() == 1 );
        ImoScore* pScore = dynamic_cast<ImoScore*>( pDoc->get_content_item(0) );
        CHECK( pScore != nullptr );
        CHECK( pScore && pScore->get_num_instruments() == 1 );
        CHECK( pScore && pScore->get_staffobjs_table() != nullptr );
        ImoInstrument* pInstr = pScore->get_instrument(0);
        CHECK( pInstr != nullptr );
        CHECK( pInstr && pInstr->get_num_staves() == 1 );
        ImoMusicData* pMD = pInstr->get_musicdata();
        CHECK( pMD != nullptr );
        CHECK( pMD && pMD->get_num_items() == 5 );
        ImoObj* pImo = pMD->get_first_child();
        CHECK( pImo && pImo->is_clef() == true );

//        cout << "Test: MxlCompilerFromFile_100" << endl;
//        cout << doc.to_string() << endl;

        if (pRoot && !pRoot->is_document()) delete pRoot;
    }
Esempio n. 2
0
 TEST_FIXTURE(MxlCompilerTestFixture, MxlCompilerFromString_001)
 {
     //001 - compile from string
     Document doc(m_libraryScope);
     MxlCompiler compiler(m_libraryScope, &doc);
     string src =
         "<score-partwise version='3.0'><part-list>"
         "<score-part id='P1'><part-name>Music</part-name></score-part>"
         "</part-list><part id='P1'>"
         "<measure number='1'>"
         "<attributes>"
             "<divisions>1</divisions><key><fifths>0</fifths></key>"
             "<time><beats>4</beats><beat-type>4</beat-type></time>"
             "<clef><sign>G</sign><line>2</line></clef>"
         "</attributes>"
         "<note><pitch><step>C</step><octave>4</octave></pitch><duration>4</duration><type>whole</type></note>"
         "</measure>"
         "</part></score-partwise>";
     ImoObj* pRoot =  compiler.compile_string(src);
     CHECK( compiler.get_file_locator() == "string:" );
     ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pRoot);
     CHECK( pDoc && pDoc->get_version() == "0.0" );
     CHECK( pDoc && pDoc->get_num_content_items() == 1 );
     ImoScore* pScore = dynamic_cast<ImoScore*>( pDoc->get_content_item(0) );
     CHECK( pScore != nullptr );
     CHECK( pScore && pScore->get_num_instruments() == 1 );
     CHECK( pScore && pScore->get_staffobjs_table() != nullptr );
     if (pRoot && !pRoot->is_document()) delete pRoot;
 }
Esempio n. 3
0
 TEST_FIXTURE(LmdCompilerTestFixture, LmdCompilerCreateEmpty)
 {
     Document doc(m_libraryScope);
     LmdCompiler compiler(m_libraryScope, &doc);
     InternalModel* pIModel = compiler.create_empty();
     ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pIModel->get_root());
     CHECK( pDoc->get_version() == "0.0" );
     CHECK( pDoc->get_num_content_items() == 0 );
     delete pIModel;
 }
Esempio n. 4
0
    TEST_FIXTURE(LmdCompilerTestFixture, LmdCompilerFromFile)
    {
        Document doc(m_libraryScope);
        LmdCompiler compiler(m_libraryScope, &doc);
        string path = m_scores_path + "08011-paragraph.lmd";
        InternalModel* pIModel = compiler.compile_file(path);
        CHECK( compiler.get_file_locator() == path );
        ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pIModel->get_root());
        CHECK( pDoc->get_version() == "0.0" );
        CHECK( pDoc->get_num_content_items() == 1 );
        ImoParagraph* pPara = dynamic_cast<ImoParagraph*>( pDoc->get_content_item(0) );
        CHECK( pPara != NULL );
        CHECK( pPara->get_num_items() == 1 );
        ImoTextItem* pItem = dynamic_cast<ImoTextItem*>( pPara->get_first_item() );
        CHECK( pItem->get_text() == "This is a text for this example." );

        delete pIModel;
    }
Esempio n. 5
0
 TEST_FIXTURE(LmdCompilerTestFixture, LmdCompilerFromString)
 {
     Document doc(m_libraryScope);
     LmdCompiler compiler(m_libraryScope, &doc);
     string src =
         "<lenmusdoc vers='0.0'>"
             "<content>"
                 "<ldpmusic>"
                     "(score (vers 1.6)(instrument (musicData (clef G)(n c4 q.))))"
                 "</ldpmusic>"
             "</content>"
         "</lenmusdoc>";
     InternalModel* pIModel = compiler.compile_string(src);
     CHECK( compiler.get_file_locator() == "string:" );
     ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pIModel->get_root());
     CHECK( pDoc->get_version() == "0.0" );
     CHECK( pDoc->get_num_content_items() == 1 );
     ImoScore* pScore = dynamic_cast<ImoScore*>( pDoc->get_content_item(0) );
     CHECK( pScore != NULL );
     CHECK( pScore->get_num_instruments() == 1 );
     CHECK( pScore->get_staffobjs_table() != NULL );
     CHECK( pScore->get_version_string() == "1.6" );
     delete pIModel;
 }