~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to src/tests/lomse_test_compiler.cpp

  • Committer: cecilios
  • Date: 2010-10-10 13:35:19 UTC
  • Revision ID: git-v1:2b333198c3033525d15763b84eaf79dac9fdab80
Preparing to use CMake. Updating with new code and missing files. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
//  You should have received a copy of the GNU General Public License along
14
14
//  with Lomse; if not, see <http://www.gnu.org/licenses/>.
15
15
//
16
 
//
17
 
//
18
16
//  For any comment, suggestion or feature request, please contact the manager of
19
17
//  the project at cecilios@users.sourceforge.net
20
18
//
21
19
//-------------------------------------------------------------------------------------
22
20
 
23
 
#ifdef _LM_DEBUG_
 
21
#ifdef _LOMSE_DEBUG
24
22
 
25
23
#include <UnitTest++.h>
26
24
#include <sstream>
62
60
    {
63
61
        DocumentScope documentScope(cout);
64
62
        LdpCompiler compiler(*m_pLibraryScope, documentScope);
65
 
        ImoDocument* pDoc = compiler.create_empty();
 
63
        InternalModel* pIModel = compiler.create_empty();
 
64
        ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pIModel->get_root());
66
65
        CHECK( pDoc->get_version() == "0.0" );
67
66
        CHECK( pDoc->get_num_content_items() == 0 );
 
67
        delete pIModel;
68
68
    }
69
69
 
70
70
    TEST_FIXTURE(LdpCompilerTestFixture, LdpCompilerFromString)
71
71
    {
72
 
        DocumentScope documentScope(cout);
 
72
        DocumentScope documentScope(cout); 
73
73
        LdpCompiler compiler(*m_pLibraryScope, documentScope);
74
 
        ImoDocument* pDoc = compiler.compile_string("(lenmusdoc (vers 0.0) (content (score (vers 1.6) (language en iso-8859-1) (opt Score.FillPageWithEmptyStaves true) (opt StaffLines.StopAtFinalBarline false) (instrument (musicData )))))" );
 
74
        InternalModel* pIModel = compiler.compile_string("(lenmusdoc (vers 0.0) (content (score (vers 1.6) (language en iso-8859-1) (opt Score.FillPageWithEmptyStaves true) (opt StaffLines.StopAtFinalBarline false) (instrument (musicData )))))" );
 
75
        ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pIModel->get_root());
75
76
        CHECK( pDoc->get_version() == "0.0" );
76
77
        CHECK( pDoc->get_num_content_items() == 1 );
77
78
        ImoScore* pScore = dynamic_cast<ImoScore*>( pDoc->get_content_item(0) );
79
80
        CHECK( pScore->get_num_instruments() == 1 );
80
81
        CHECK( pScore->get_staffobjs_table() != NULL );
81
82
        CHECK( pScore->get_version() == "1.6" );
 
83
        delete pIModel;
82
84
    }
83
85
 
84
86
    TEST_FIXTURE(LdpCompilerTestFixture, LdpCompilerScoreIdsFixed)
85
87
    {
86
88
        DocumentScope documentScope(cout);
87
89
        LdpCompiler compiler(*m_pLibraryScope, documentScope);
88
 
        ImoDocument* pDoc = compiler.compile_string("(score (vers 1.6) (language en iso-8859-1) (systemLayout first (systemMargins 0 0 0 2000)) (systemLayout other (systemMargins 0 0 1200 2000)) (opt Score.FillPageWithEmptyStaves true) (opt StaffLines.StopAtFinalBarline false) (instrument (musicData )))" );
 
90
        InternalModel* pIModel = compiler.compile_string("(score (vers 1.6) (language en iso-8859-1) (systemLayout first (systemMargins 0 0 0 2000)) (systemLayout other (systemMargins 0 0 1200 2000)) (opt Score.FillPageWithEmptyStaves true) (opt StaffLines.StopAtFinalBarline false) (instrument (musicData )))" );
 
91
        ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pIModel->get_root());
89
92
        CHECK( pDoc->get_version() == "0.0" );
90
93
        CHECK( pDoc->get_num_content_items() == 1 );
91
94
        ImoScore* pScore = dynamic_cast<ImoScore*>( pDoc->get_content_item(0) );
92
95
        CHECK( pScore != NULL );
 
96
        //cout << "id=" << pScore->get_id() << endl;
93
97
        CHECK( pScore->get_id() == 3L );
94
98
        CHECK( pScore->get_num_instruments() == 1 );
95
99
        ImoInstrument* pInstr = pScore->get_instrument(0);
96
100
        CHECK( pInstr->get_id() == 12L );
 
101
        delete pIModel;
97
102
    }
98
103
 
99
104
    TEST_FIXTURE(LdpCompilerTestFixture, LdpCompilerFromFile)
100
105
    {
101
106
        DocumentScope documentScope(cout);
102
107
        LdpCompiler compiler(*m_pLibraryScope, documentScope);
103
 
        ImoDocument* pDoc = compiler.compile_file(m_scores_path + "00011-empty-fill-page.lms");
 
108
        InternalModel* pIModel = compiler.compile_file(m_scores_path + "00011-empty-fill-page.lms");
 
109
        ImoDocument* pDoc = dynamic_cast<ImoDocument*>(pIModel->get_root());
104
110
        CHECK( pDoc->get_version() == "0.0" );
105
111
        CHECK( pDoc->get_num_content_items() == 1 );
106
112
        ImoScore* pScore = dynamic_cast<ImoScore*>( pDoc->get_content_item(0) );
109
115
        CHECK( pScore->get_num_instruments() == 1 );
110
116
        ImoInstrument* pInstr = pScore->get_instrument(0);
111
117
        CHECK( pInstr->get_id() == 12L );
 
118
        delete pIModel;
112
119
    }
113
120
 
114
121
//    TEST_FIXTURE(LdpCompilerTestFixture, LdpCompilerCreateElement)
119
126
//        CHECK( pElm != NULL );
120
127
//        //cout << pElm->to_string() << endl;
121
128
//        CHECK( pElm->to_string() == "(systemLayout first (systemMargins 0 0 0 2000))" );
122
 
//        BasicModel* pBasicModel = compiler.get_outcome();
123
 
//        delete pBasicModel;
 
129
//        InternalModel* IModel = compiler.get_outcome();
 
130
//        delete IModel;
124
131
//        delete pElm;
125
132
//    }
126
133
//
128
135
//    {
129
136
//        DocumentScope documentScope(cout);
130
137
//        LdpCompiler compiler(*m_pLibraryScope, documentScope);
131
 
//        BasicModel* pBasicModel = compiler.create_basic_model("(n e4 q.)" );
132
 
//        DtoObj* pObj = pBasicModel->get_root();
 
138
//        InternalModel* IModel = compiler.create_basic_model("(n e4 q.)" );
 
139
//        DtoObj* pObj = IModel->get_root();
133
140
//        CHECK( pObj != NULL );
134
141
//        CHECK( pObj->is_note() == true );
135
 
//        delete pBasicModel;
 
142
//        delete IModel;
136
143
//    }
137
144
 
138
145
};
139
146
 
140
 
#endif  // _LM_DEBUG_
 
147
#endif  // _LOMSE_DEBUG
141
148