Fix insane formatting/whitespace in evoral test stuff. C'mon Hans ;)

git-svn-id: svn://localhost/ardour2/branches/3.0@5799 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-10-19 15:26:56 +00:00
parent cb8407d26f
commit a2c434d5cd
5 changed files with 92 additions and 93 deletions

View file

@ -20,15 +20,15 @@ SMFTest::takeFiveTest ()
TestSMF smf; TestSMF smf;
smf.open("./test/testdata/TakeFive.mid"); smf.open("./test/testdata/TakeFive.mid");
CPPUNIT_ASSERT(!smf.is_empty()); CPPUNIT_ASSERT(!smf.is_empty());
seq->start_write(); seq->start_write();
smf.seek_to_start(); smf.seek_to_start();
uint64_t time = 0; /* in SMF ticks */ uint64_t time = 0; /* in SMF ticks */
Evoral::Event<double> ev; Evoral::Event<double> ev;
const double frames_per_beat = 100.0; const double frames_per_beat = 100.0;
uint32_t delta_t = 0; uint32_t delta_t = 0;
uint32_t size = 0; uint32_t size = 0;
uint8_t* buf = NULL; uint8_t* buf = NULL;
@ -36,7 +36,7 @@ SMFTest::takeFiveTest ()
while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) { while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) {
ev.set(buf, size, 0.0); ev.set(buf, size, 0.0);
time += delta_t; time += delta_t;
if (ret > 0) { // didn't skip (meta) event if (ret > 0) { // didn't skip (meta) event
//cerr << "read smf event type " << hex << int(buf[0]) << endl; //cerr << "read smf event type " << hex << int(buf[0]) << endl;
// make ev.time absolute time in frames // make ev.time absolute time in frames

View file

@ -1,16 +1,16 @@
/* This file is part of Evoral. /* This file is part of Evoral.
* Copyright(C) 2000-2008 Paul Davis * Copyright(C) 2000-2008 Paul Davis
* Author: Hans Baier * Author: Hans Baier
* *
* Evoral is free software; you can redistribute it and/or modify it under the * Evoral 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 * 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 * Foundation; either version 2 of the License, or(at your option) any later
* version. * version.
* *
* Evoral is distributed in the hope that it will be useful, but WITHOUT ANY * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
* *
* You should have received a copy of the GNU General Public License along * 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., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@ -29,16 +29,16 @@ using namespace Evoral;
class TestSMF : public SMF { class TestSMF : public SMF {
public: public:
std::string path() const { return _path; } std::string path() const { return _path; }
int open(const std::string& path) THROW_FILE_ERROR { int open(const std::string& path) THROW_FILE_ERROR {
_path = path; _path = path;
return SMF::open(path); return SMF::open(path);
} }
void close() THROW_FILE_ERROR { void close() THROW_FILE_ERROR {
return SMF::close(); return SMF::close();
} }
int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const { int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
return SMF::read_event(delta_t, size, buf); return SMF::read_event(delta_t, size, buf);
} }
@ -49,31 +49,31 @@ private:
class SMFTest : public CppUnit::TestFixture class SMFTest : public CppUnit::TestFixture
{ {
CPPUNIT_TEST_SUITE(SMFTest); CPPUNIT_TEST_SUITE(SMFTest);
CPPUNIT_TEST(createNewFileTest); CPPUNIT_TEST(createNewFileTest);
CPPUNIT_TEST(takeFiveTest); CPPUNIT_TEST(takeFiveTest);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
public: public:
typedef double Time; typedef double Time;
void setUp() {
type_map = new DummyTypeMap();
assert(type_map);
seq = new MySequence<Time>(*type_map);
assert(seq);
}
void tearDown() {
delete seq;
delete type_map;
}
void createNewFileTest(); void setUp() {
void takeFiveTest(); type_map = new DummyTypeMap();
assert(type_map);
seq = new MySequence<Time>(*type_map);
assert(seq);
}
private: void tearDown() {
DummyTypeMap* type_map; delete seq;
MySequence<Time>* seq; delete type_map;
}
void createNewFileTest();
void takeFiveTest();
private:
DummyTypeMap* type_map;
MySequence<Time>* seq;
}; };

View file

@ -5,7 +5,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SequenceTest);
using namespace std; using namespace std;
void void
SequenceTest::createTest (void) SequenceTest::createTest (void)
{ {
CPPUNIT_ASSERT_EQUAL(size_t(0), seq->sysexes().size()); CPPUNIT_ASSERT_EQUAL(size_t(0), seq->sysexes().size());
@ -14,23 +14,23 @@ SequenceTest::createTest (void)
} }
void void
SequenceTest::preserveEventOrderingTest (void) SequenceTest::preserveEventOrderingTest (void)
{ {
vector< boost::shared_ptr< Event<Time> > > inserted_events; vector< boost::shared_ptr< Event<Time> > > inserted_events;
seq->start_write(); seq->start_write();
for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) { for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) {
uint8_t buffer[2]; uint8_t buffer[2];
Event<Time>* event = new Event<Time>( Event<Time>* event = new Event<Time>(
DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true
); );
event->buffer()[0] = MIDI_CMD_CONTROL; event->buffer()[0] = MIDI_CMD_CONTROL;
event->buffer()[1] = event->time() / 100; event->buffer()[1] = event->time() / 100;
event->buffer()[2] = event->time() / 100; event->buffer()[2] = event->time() / 100;
boost::shared_ptr<Event<Time> > event_ptr(event); boost::shared_ptr<Event<Time> > event_ptr(event);
seq->append((*i)->on_event()); seq->append((*i)->on_event());
@ -38,17 +38,17 @@ SequenceTest::preserveEventOrderingTest (void)
boost::shared_ptr<Event<Time> >( boost::shared_ptr<Event<Time> >(
new Event<Time>((*i)->on_event(), true) new Event<Time>((*i)->on_event(), true)
)); ));
seq->append(*event_ptr); seq->append(*event_ptr);
inserted_events.push_back(event_ptr); inserted_events.push_back(event_ptr);
seq->append((*i)->off_event()); seq->append((*i)->off_event());
inserted_events.push_back( inserted_events.push_back(
boost::shared_ptr<Event<Time> >( boost::shared_ptr<Event<Time> >(
new Event<Time>((*i)->off_event(), true) new Event<Time>((*i)->off_event(), true)
)); ));
} }
seq->end_write(); seq->end_write();
TestSink<Time> sink; TestSink<Time> sink;
@ -58,7 +58,7 @@ SequenceTest::preserveEventOrderingTest (void)
for (MySequence<Time>::const_iterator i = seq->begin(); i != seq->end(); ++i) { for (MySequence<Time>::const_iterator i = seq->begin(); i != seq->end(); ++i) {
sink.write(i->time(), i->event_type(), i->size(), i->buffer()); sink.write(i->time(), i->event_type(), i->size(), i->buffer());
} }
CPPUNIT_ASSERT_EQUAL(size_t(12), test_notes.size()); CPPUNIT_ASSERT_EQUAL(size_t(12), test_notes.size());
} }

View file

@ -12,13 +12,13 @@ using namespace Evoral;
class DummyTypeMap : public TypeMap { class DummyTypeMap : public TypeMap {
public: public:
enum DummyEventType { enum DummyEventType {
NOTE, NOTE,
CONTROL, CONTROL,
SYSEX SYSEX
}; };
~DummyTypeMap() {} ~DummyTypeMap() {}
bool type_is_midi (uint32_t /*type*/) const {return true;} bool type_is_midi (uint32_t /*type*/) const {return true;}
@ -28,18 +28,18 @@ public:
case CONTROL: return MIDI_CMD_CONTROL; case CONTROL: return MIDI_CMD_CONTROL;
case SYSEX: return MIDI_CMD_COMMON_SYSEX; case SYSEX: return MIDI_CMD_COMMON_SYSEX;
default: return 0; default: return 0;
}; };
} }
uint32_t midi_event_type(uint8_t status) const { uint32_t midi_event_type(uint8_t status) const {
status &= 0xf0; status &= 0xf0;
switch (status) { switch (status) {
case MIDI_CMD_CONTROL: return CONTROL; case MIDI_CMD_CONTROL: return CONTROL;
case MIDI_CMD_COMMON_SYSEX: return SYSEX; case MIDI_CMD_COMMON_SYSEX: return SYSEX;
default: return 0; default: return 0;
}; };
} }
bool is_integer (const Evoral::Parameter& /*param*/) const {return true;} bool is_integer (const Evoral::Parameter& /*param*/) const {return true;}
Parameter new_parameter(uint32_t type, uint8_t channel, uint32_t id) const { Parameter new_parameter(uint32_t type, uint8_t channel, uint32_t id) const {
@ -55,9 +55,9 @@ template<typename Time>
class MySequence : public Sequence<Time> { class MySequence : public Sequence<Time> {
public: public:
MySequence(DummyTypeMap&map) : Sequence<Time>(map) {} MySequence(DummyTypeMap&map) : Sequence<Time>(map) {}
boost::shared_ptr<Control> control_factory(const Parameter& param) { boost::shared_ptr<Control> control_factory(const Parameter& param) {
return boost::shared_ptr<Control>( return boost::shared_ptr<Control>(
new Control(param, boost::shared_ptr<ControlList> ( new Control(param, boost::shared_ptr<ControlList> (
new ControlList(param) new ControlList(param)
@ -69,65 +69,64 @@ template<typename Time>
class TestSink : public EventSink<Time> { class TestSink : public EventSink<Time> {
public: public:
TestSink() : _last_event_time(-1) {} TestSink() : _last_event_time(-1) {}
/// return value, time, type, size, buffer /// return value, time, type, size, buffer
sigc::signal<uint32_t, Time, EventType, uint32_t, const uint8_t*> writing; sigc::signal<uint32_t, Time, EventType, uint32_t, const uint8_t*> writing;
virtual uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf) { virtual uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf) {
//std::cerr << "last event time: " << _last_event_time << " time: " << time << std::endl; //std::cerr << "last event time: " << _last_event_time << " time: " << time << std::endl;
uint32_t result = writing(time, type, size, buf); uint32_t result = writing(time, type, size, buf);
_last_event_time = time; _last_event_time = time;
return result; return result;
} }
uint32_t assertLastEventTimeEarlier( uint32_t assertLastEventTimeEarlier(
Time time, EventType /*type*/, uint32_t /*size*/, const uint8_t* /*buf*/) { Time time, EventType /*type*/, uint32_t /*size*/, const uint8_t* /*buf*/) {
CPPUNIT_ASSERT(_last_event_time <= time); CPPUNIT_ASSERT(_last_event_time <= time);
return 0; return 0;
} }
Time last_event_time() const { return _last_event_time; } Time last_event_time() const { return _last_event_time; }
private: private:
Time _last_event_time; Time _last_event_time;
}; };
class SequenceTest : public CppUnit::TestFixture class SequenceTest : public CppUnit::TestFixture
{ {
CPPUNIT_TEST_SUITE (SequenceTest); CPPUNIT_TEST_SUITE (SequenceTest);
CPPUNIT_TEST (createTest); CPPUNIT_TEST (createTest);
CPPUNIT_TEST (preserveEventOrderingTest); CPPUNIT_TEST (preserveEventOrderingTest);
CPPUNIT_TEST_SUITE_END (); CPPUNIT_TEST_SUITE_END ();
public: public:
typedef double Time;
typedef double Time; typedef std::vector<boost::shared_ptr<Note<Time> > > Notes;
typedef std::vector<boost::shared_ptr<Note<Time> > > Notes;
void setUp (void) {
void setUp (void) { type_map = new DummyTypeMap();
type_map = new DummyTypeMap(); assert(type_map);
assert(type_map); seq = new MySequence<Time>(*type_map);
seq = new MySequence<Time>(*type_map); assert(seq);
assert(seq);
for (int i = 0; i < 12; i++) {
for(int i = 0; i < 12; i++) { test_notes.push_back(boost::shared_ptr<Note<Time> >
test_notes.push_back(boost::shared_ptr<Note<Time> >
(new Note<Time>(0, i * 100, 100, 64 + i, 64))); (new Note<Time>(0, i * 100, 100, 64 + i, 64)));
} }
} }
void tearDown (void) {
test_notes.clear();
delete seq;
delete type_map;
}
void createTest (void); void tearDown (void) {
void preserveEventOrderingTest (void); test_notes.clear();
delete seq;
delete type_map;
}
private: void createTest (void);
DummyTypeMap* type_map; void preserveEventOrderingTest (void);
MySequence<Time>* seq;
private:
Notes test_notes; DummyTypeMap* type_map;
MySequence<Time>* seq;
Notes test_notes;
}; };

View file

@ -11,7 +11,7 @@ int
main() main()
{ {
Glib::thread_init(); Glib::thread_init();
CppUnit::TestResult testresult; CppUnit::TestResult testresult;
CppUnit::TestResultCollector collectedresults; CppUnit::TestResultCollector collectedresults;