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/>.
18
16
// For any comment, suggestion or feature request, please contact the manager of
19
17
// the project at cecilios@users.sourceforge.net
21
19
//-------------------------------------------------------------------------------------
25
23
#include <UnitTest++.h>
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 );
70
70
TEST_FIXTURE(LdpCompilerTestFixture, LdpCompilerFromString)
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" );
84
86
TEST_FIXTURE(LdpCompilerTestFixture, LdpCompilerScoreIdsFixed)
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 );
99
104
TEST_FIXTURE(LdpCompilerTestFixture, LdpCompilerFromFile)
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 );
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();
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;
147
#endif // _LOMSE_DEBUG