13
0
livetrax/libs/evoral/test/SequenceTest.cpp
David Robillard 5a48f99f72 Use nframes_t for timestamps of real (jack) time MIDI events (i.e. in MidiBuffer and MidiRingBuffer).
Use iterator interface of Sequence to read events in a MIDISource rather than Sequence::read, avoiding timestamp confusion.
Disable no longer useful Sequence::read.


git-svn-id: svn://localhost/ardour2/branches/3.0@4570 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-02-15 01:24:26 +00:00

65 lines
1.6 KiB
C++

#include "SequenceTest.hpp"
#include <cassert>
CPPUNIT_TEST_SUITE_REGISTRATION(SequenceTest);
using namespace std;
void
SequenceTest::createTest (void)
{
CPPUNIT_ASSERT_EQUAL(size_t(0), seq->sysexes().size());
CPPUNIT_ASSERT_EQUAL(size_t(0), seq->notes().size());
CPPUNIT_ASSERT(seq->notes().begin() == seq->notes().end());
}
void
SequenceTest::preserveEventOrderingTest (void)
{
vector< boost::shared_ptr< Event<Time> > > inserted_events;
seq->start_write();
for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) {
uint8_t buffer[2];
Event<Time>* event = new Event<Time>(
DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true
);
event->buffer()[0] = MIDI_CMD_CONTROL;
event->buffer()[1] = event->time() / 100;
event->buffer()[2] = event->time() / 100;
boost::shared_ptr<Event<Time> > event_ptr(event);
seq->append((*i)->on_event());
inserted_events.push_back(
boost::shared_ptr<Event<Time> >(
new Event<Time>((*i)->on_event(), true)
));
seq->append(*event_ptr);
inserted_events.push_back(event_ptr);
seq->append((*i)->off_event());
inserted_events.push_back(
boost::shared_ptr<Event<Time> >(
new Event<Time>((*i)->off_event(), true)
));
}
seq->end_write();
TestSink<Time> sink;
sink.writing.connect(sigc::mem_fun(&sink, &TestSink<Time>::assertLastEventTimeEarlier));
for (MySequence<Time>::const_iterator i = seq->begin(); i != seq->end(); ++i) {
sink.write(i->time(), i->event_type(), i->size(), i->buffer());
}
CPPUNIT_ASSERT_EQUAL(size_t(12), test_notes.size());
}