smf_delete(_smf);
}
- _smf = smf_load(path.c_str());
+ _path = path;
+ assert(_path != "");
+
+ _smf = smf_load(_path.c_str());
if (!_smf) {
_smf = smf_new();
if (smf_set_ppqn(_smf, _ppqn) != 0) {
if(_smf == NULL) {
return -1;
}
+
+ _smf_track = smf_track_new();
+ assert(_smf_track);
+
+ smf_add_track(_smf, _smf_track);
}
_smf_track = smf_get_track_by_number(_smf, 1);
void
LibSMF<Time>::close() THROW_FILE_ERROR
{
- assert(false);
if (_smf) {
if (smf_save(_smf, _path.c_str()) != 0) {
throw typename MIDIFile<Time>::FileError();
CPPUNIT_TEST_SUITE_REGISTRATION( SMFTest );
+void
+SMFTest::createNewFileTest ()
+{
+ TestSMF<Time> smf;
+ smf.open("NewFile.mid");
+ smf.close();
+ CPPUNIT_ASSERT(access(smf.path().c_str(), R_OK) == 0);
+ unlink(smf.path().c_str());
+}
+
void
SMFTest::takeFiveTest ()
{
template<typename Time>
class TestSMF : public LibSMF<Time> {
public:
+ std::string path() const { return _path; }
+
int open(const std::string& path) THROW_FILE_ERROR {
+ _path = path;
return LibSMF<Time>::open(path);
}
+ void close() THROW_FILE_ERROR {
+ return LibSMF<Time>::close();
+ }
+
int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
return LibSMF<Time>::read_event(delta_t, size, buf);
}
+
+private:
+
+ std::string _path;
+
};
class SMFTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE (SMFTest);
+ CPPUNIT_TEST (createNewFileTest);
CPPUNIT_TEST (takeFiveTest);
CPPUNIT_TEST_SUITE_END ();
delete type_map;
}
+ void createNewFileTest(void);
void takeFiveTest (void);
private: