* Evoral: SMFTest: added createNewFileTest (passes)
git-svn-id: svn://localhost/ardour2/branches/3.0@4540 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
9d33176b49
commit
e7c7c33563
@ -52,7 +52,10 @@ LibSMF<Time>::open(const std::string& path) THROW_FILE_ERROR
|
||||
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) {
|
||||
@ -62,6 +65,11 @@ LibSMF<Time>::open(const std::string& path) THROW_FILE_ERROR
|
||||
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);
|
||||
@ -78,7 +86,6 @@ template<typename Time>
|
||||
void
|
||||
LibSMF<Time>::close() THROW_FILE_ERROR
|
||||
{
|
||||
assert(false);
|
||||
if (_smf) {
|
||||
if (smf_save(_smf, _path.c_str()) != 0) {
|
||||
throw typename MIDIFile<Time>::FileError();
|
||||
|
@ -4,6 +4,16 @@ using namespace std;
|
||||
|
||||
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 ()
|
||||
{
|
||||
|
@ -14,18 +14,31 @@ using namespace Evoral;
|
||||
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 ();
|
||||
|
||||
@ -45,6 +58,7 @@ class SMFTest : public CppUnit::TestFixture
|
||||
delete type_map;
|
||||
}
|
||||
|
||||
void createNewFileTest(void);
|
||||
void takeFiveTest (void);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user