2019-08-02 23:10:55 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2016 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009 Hans Baier <hansfbaier@googlemail.com>
|
2009-10-19 11:26:56 -04:00
|
|
|
*
|
2019-08-02 23:10:55 -04:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2009-10-19 11:26:56 -04:00
|
|
|
*
|
2019-08-02 23:10:55 -04:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-10-19 11:26:56 -04:00
|
|
|
*
|
2009-02-14 12:35:34 -05:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2019-08-02 23:10:55 -04:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-02-14 12:35:34 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cassert>
|
2009-05-17 20:21:17 -04:00
|
|
|
#include <stdint.h>
|
2009-02-14 12:35:34 -05:00
|
|
|
#include <sigc++/sigc++.h>
|
2009-02-09 17:32:38 -05:00
|
|
|
#include <cppunit/TestFixture.h>
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
2019-09-05 08:08:31 -04:00
|
|
|
#include "temporal/beats.h"
|
2009-02-14 12:35:34 -05:00
|
|
|
#include "evoral/SMF.hpp"
|
2009-02-10 18:58:02 -05:00
|
|
|
#include "SequenceTest.hpp"
|
|
|
|
|
|
|
|
using namespace Evoral;
|
|
|
|
|
2009-02-14 20:32:41 -05:00
|
|
|
class TestSMF : public SMF {
|
2009-02-10 18:58:02 -05:00
|
|
|
public:
|
2009-02-12 18:28:51 -05:00
|
|
|
std::string path() const { return _path; }
|
2009-10-19 11:26:56 -04:00
|
|
|
|
2009-02-11 12:59:33 -05:00
|
|
|
int open(const std::string& path) THROW_FILE_ERROR {
|
2009-02-12 18:28:51 -05:00
|
|
|
_path = path;
|
2009-02-14 20:32:41 -05:00
|
|
|
return SMF::open(path);
|
2009-02-10 18:58:02 -05:00
|
|
|
}
|
2009-10-19 11:26:56 -04:00
|
|
|
|
2009-02-12 18:28:51 -05:00
|
|
|
void close() THROW_FILE_ERROR {
|
2009-02-14 20:32:41 -05:00
|
|
|
return SMF::close();
|
2009-02-12 18:28:51 -05:00
|
|
|
}
|
2009-10-19 11:26:56 -04:00
|
|
|
|
2009-02-10 18:58:02 -05:00
|
|
|
int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
|
2010-07-24 20:39:04 -04:00
|
|
|
event_id_t id;
|
|
|
|
return SMF::read_event(delta_t, size, buf, &id);
|
2009-02-10 18:58:02 -05:00
|
|
|
}
|
2009-02-12 18:28:51 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _path;
|
2009-02-10 18:58:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class SMFTest : public CppUnit::TestFixture
|
|
|
|
{
|
2009-10-19 11:26:56 -04:00
|
|
|
CPPUNIT_TEST_SUITE(SMFTest);
|
|
|
|
CPPUNIT_TEST(createNewFileTest);
|
|
|
|
CPPUNIT_TEST(takeFiveTest);
|
2016-12-04 15:40:21 -05:00
|
|
|
CPPUNIT_TEST(writeTest);
|
2009-10-19 11:26:56 -04:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
2009-02-10 18:58:02 -05:00
|
|
|
|
2009-10-19 11:26:56 -04:00
|
|
|
public:
|
2019-09-05 08:08:31 -04:00
|
|
|
typedef Temporal::Beats Time;
|
2009-02-10 18:58:02 -05:00
|
|
|
|
2009-10-19 11:26:56 -04:00
|
|
|
void setUp() {
|
|
|
|
type_map = new DummyTypeMap();
|
|
|
|
assert(type_map);
|
|
|
|
seq = new MySequence<Time>(*type_map);
|
|
|
|
assert(seq);
|
|
|
|
}
|
2009-02-10 18:58:02 -05:00
|
|
|
|
2009-10-19 11:26:56 -04:00
|
|
|
void tearDown() {
|
|
|
|
delete seq;
|
|
|
|
delete type_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
void createNewFileTest();
|
|
|
|
void takeFiveTest();
|
2016-12-04 15:40:21 -05:00
|
|
|
void writeTest();
|
2009-10-19 11:26:56 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
DummyTypeMap* type_map;
|
|
|
|
MySequence<Time>* seq;
|
2009-02-10 18:58:02 -05:00
|
|
|
};
|
2009-02-14 12:35:34 -05:00
|
|
|
|