13
0

* Sequence: added asserts

* sequence.cpp completed first test


git-svn-id: svn://localhost/ardour2/branches/3.0@4504 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2009-02-09 08:49:57 +00:00
parent fcfe073b00
commit 9734fa3e93
3 changed files with 28 additions and 10 deletions

View File

@ -220,6 +220,8 @@ Sequence<T>::const_iterator::const_iterator(const Sequence<T>& seq, T t)
debugout << " @ " << _event->time() << endl;
}
assert(_event && _event->size() > 0);
//assert(_is_end || (_event->buffer() && _event->buffer()[0] != '\0'));
}
@ -240,7 +242,7 @@ Sequence<T>::const_iterator::operator++()
}
debugout << "Iterator ++" << endl;
assert(_event->buffer() && _event->size() > 0);
assert(_event && _event->buffer() && _event->size() > 0);
const MIDIEvent<T>& ev = *((MIDIEvent<T>*)_event.get());

View File

@ -13,6 +13,7 @@ SequenceTest::createTest (void)
CPPUNIT_ASSERT(seq->notes().begin() == seq->notes().end());
}
void
SequenceTest::preserveEventOrderingTest (void)
{
@ -50,6 +51,7 @@ SequenceTest::preserveEventOrderingTest (void)
seq->end_write();
TestSink<Time> sink;
sink.writing.connect(sigc::mem_fun(&sink, &TestSink<Time>::assertLastEventTimeLessOrEqualEventTime));
seq->read(sink, timestamp_t(0), timedur_t(1200), timestamp_t(0));

View File

@ -29,18 +29,18 @@ public:
uint8_t parameter_midi_type(const Parameter& param) const {
switch (param.type()) {
case CONTROL: return MIDI_CMD_CONTROL;
case SYSEX: return MIDI_CMD_COMMON_SYSEX;
default: return 0;
case CONTROL: return MIDI_CMD_CONTROL;
case SYSEX: return MIDI_CMD_COMMON_SYSEX;
default: return 0;
};
}
uint32_t midi_event_type(uint8_t status) const {
status &= 0xf0;
switch (status) {
case MIDI_CMD_CONTROL: return CONTROL;
case MIDI_CMD_COMMON_SYSEX: return SYSEX;
default: return 0;
case MIDI_CMD_CONTROL: return CONTROL;
case MIDI_CMD_COMMON_SYSEX: return SYSEX;
default: return 0;
};
}
@ -72,11 +72,27 @@ public:
template<typename Time>
class TestSink : public EventSink<Time> {
public:
TestSink() : _last_event_time(-1) {}
/// return value, time, type, size, buffer
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) {
return writing(time, type, size, buf);
std::cerr << "last event time: " << _last_event_time << " time: " << time << std::endl;
uint32_t result = writing(time, type, size, buf);
_last_event_time = time;
return result;
}
uint32_t assertLastEventTimeLessOrEqualEventTime(
Time time, EventType type, uint32_t size, const uint8_t* buf) {
assert(_last_event_time <= time);
}
Time last_event_time() const { return _last_event_time; }
private:
Time _last_event_time;
};
class SequenceTest : public CppUnit::TestFixture
@ -118,6 +134,4 @@ class SequenceTest : public CppUnit::TestFixture
MySequence<Time>* seq;
Notes test_notes;
};