Improve coverage of evoral tests
This commit is contained in:
parent
9aac954744
commit
9dbc524060
@ -38,6 +38,54 @@ using namespace Evoral;
|
|||||||
); \
|
); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CurveTest::trivial ()
|
||||||
|
{
|
||||||
|
float vec[1024];
|
||||||
|
|
||||||
|
boost::shared_ptr<Evoral::ControlList> cl = TestCtrlList();
|
||||||
|
|
||||||
|
cl->create_curve ();
|
||||||
|
|
||||||
|
// Empty curve
|
||||||
|
cl->curve().get_vector (1024.0, 2047.0, vec, 1024);
|
||||||
|
for (int i = 0; i < 1024; ++i) {
|
||||||
|
CPPUNIT_ASSERT_EQUAL (0.0f, vec[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single point curve
|
||||||
|
cl->fast_simple_add(0.0, 42.0);
|
||||||
|
cl->curve().get_vector (1024.0, 2047.0, vec, 1024);
|
||||||
|
for (int i = 0; i < 1024; ++i) {
|
||||||
|
CPPUNIT_ASSERT_EQUAL (42.0f, vec[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CurveTest::rtGet ()
|
||||||
|
{
|
||||||
|
float vec[1024];
|
||||||
|
|
||||||
|
// Create simple control list
|
||||||
|
boost::shared_ptr<Evoral::ControlList> cl = TestCtrlList();
|
||||||
|
cl->create_curve ();
|
||||||
|
cl->fast_simple_add(0.0, 42.0);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Write-lock list
|
||||||
|
Glib::Threads::RWLock::WriterLock lm(cl->lock());
|
||||||
|
|
||||||
|
// Attempt to get vector in RT (expect failure)
|
||||||
|
CPPUNIT_ASSERT (!cl->curve().rt_safe_get_vector (1024.0, 2047.0, vec, 1024));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to get vector in RT (expect success)
|
||||||
|
CPPUNIT_ASSERT (cl->curve().rt_safe_get_vector (1024.0, 2047.0, vec, 1024));
|
||||||
|
for (int i = 0; i < 1024; ++i) {
|
||||||
|
CPPUNIT_ASSERT_EQUAL (42.0f, vec[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CurveTest::twoPointLinear ()
|
CurveTest::twoPointLinear ()
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
class CurveTest : public CppUnit::TestFixture
|
class CurveTest : public CppUnit::TestFixture
|
||||||
{
|
{
|
||||||
CPPUNIT_TEST_SUITE (CurveTest);
|
CPPUNIT_TEST_SUITE (CurveTest);
|
||||||
|
CPPUNIT_TEST (trivial);
|
||||||
|
CPPUNIT_TEST (rtGet);
|
||||||
CPPUNIT_TEST (twoPointLinear);
|
CPPUNIT_TEST (twoPointLinear);
|
||||||
CPPUNIT_TEST (threePointLinear);
|
CPPUNIT_TEST (threePointLinear);
|
||||||
CPPUNIT_TEST (threePointDiscete);
|
CPPUNIT_TEST (threePointDiscete);
|
||||||
@ -14,6 +16,8 @@ class CurveTest : public CppUnit::TestFixture
|
|||||||
CPPUNIT_TEST_SUITE_END ();
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void trivial ();
|
||||||
|
void rtGet ();
|
||||||
void twoPointLinear ();
|
void twoPointLinear ();
|
||||||
void threePointLinear ();
|
void threePointLinear ();
|
||||||
void threePointDiscete ();
|
void threePointDiscete ();
|
||||||
|
@ -14,6 +14,18 @@ SequenceTest::createTest ()
|
|||||||
CPPUNIT_ASSERT(seq->notes().begin() == seq->notes().end());
|
CPPUNIT_ASSERT(seq->notes().begin() == seq->notes().end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SequenceTest::copyTest ()
|
||||||
|
{
|
||||||
|
DummyTypeMap map;
|
||||||
|
MySequence<Time> a(map);
|
||||||
|
for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) {
|
||||||
|
a.notes().insert(*i);
|
||||||
|
}
|
||||||
|
|
||||||
|
MySequence<Time> b(a);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(b.notes().size(), a.notes().size());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SequenceTest::preserveEventOrderingTest ()
|
SequenceTest::preserveEventOrderingTest ()
|
||||||
@ -74,6 +86,7 @@ SequenceTest::iteratorSeekTest ()
|
|||||||
seq->notes().insert(*i);
|
seq->notes().insert(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iterate over all notes
|
||||||
bool on = true;
|
bool on = true;
|
||||||
for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats(600)); i != seq->end(); ++i) {
|
for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats(600)); i != seq->end(); ++i) {
|
||||||
if (on) {
|
if (on) {
|
||||||
@ -87,7 +100,38 @@ SequenceTest::iteratorSeekTest ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(num_notes, size_t(6));
|
CPPUNIT_ASSERT_EQUAL(size_t(6), num_notes);
|
||||||
|
|
||||||
|
// Test invalidation
|
||||||
|
Sequence<Time>::const_iterator i = seq->begin(Time(600));
|
||||||
|
std::set< boost::weak_ptr< Note<Time> > > active_notes;
|
||||||
|
i.invalidate(&active_notes);
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)1, active_notes.size());
|
||||||
|
|
||||||
|
// Test resuming after invalidation
|
||||||
|
i = seq->begin(Time(601), false, std::set<Evoral::Parameter>(), &active_notes);
|
||||||
|
CPPUNIT_ASSERT(i->is_note_off());
|
||||||
|
on = false;
|
||||||
|
num_notes = 1;
|
||||||
|
for (; i != seq->end(); ++i) {
|
||||||
|
if (on) {
|
||||||
|
CPPUNIT_ASSERT(i->is_note_on());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(Time((num_notes + 6) * 100), i->time());
|
||||||
|
++num_notes;
|
||||||
|
on = false;
|
||||||
|
} else {
|
||||||
|
CPPUNIT_ASSERT(i->is_note_off());
|
||||||
|
on = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(size_t(6), num_notes);
|
||||||
|
|
||||||
|
// Test equality of copied iterators
|
||||||
|
i = seq->begin();
|
||||||
|
++i;
|
||||||
|
Sequence<Time>::const_iterator j = i;
|
||||||
|
CPPUNIT_ASSERT(i == j);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -149,9 +193,4 @@ SequenceTest::controlInterpolationTest ()
|
|||||||
last_time = i->first;
|
last_time = i->first;
|
||||||
last_value = i->second;
|
last_value = i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add some notes
|
|
||||||
for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) {
|
|
||||||
seq->notes().insert(*i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ 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) {}
|
||||||
|
MySequence(const MySequence& copy) : ControlSet(copy), Sequence<Time>(copy) {}
|
||||||
|
|
||||||
virtual bool find_next_event(double start, double end, ControlEvent& ev, bool only_active) const { return false; }
|
virtual bool find_next_event(double start, double end, ControlEvent& ev, bool only_active) const { return false; }
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ class SequenceTest : public CppUnit::TestFixture
|
|||||||
{
|
{
|
||||||
CPPUNIT_TEST_SUITE (SequenceTest);
|
CPPUNIT_TEST_SUITE (SequenceTest);
|
||||||
CPPUNIT_TEST (createTest);
|
CPPUNIT_TEST (createTest);
|
||||||
|
CPPUNIT_TEST (copyTest);
|
||||||
CPPUNIT_TEST (preserveEventOrderingTest);
|
CPPUNIT_TEST (preserveEventOrderingTest);
|
||||||
CPPUNIT_TEST (iteratorSeekTest);
|
CPPUNIT_TEST (iteratorSeekTest);
|
||||||
CPPUNIT_TEST (controlInterpolationTest);
|
CPPUNIT_TEST (controlInterpolationTest);
|
||||||
@ -140,6 +142,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void createTest ();
|
void createTest ();
|
||||||
|
void copyTest ();
|
||||||
void preserveEventOrderingTest ();
|
void preserveEventOrderingTest ();
|
||||||
void iteratorSeekTest ();
|
void iteratorSeekTest ();
|
||||||
void controlInterpolationTest ();
|
void controlInterpolationTest ();
|
||||||
|
Loading…
Reference in New Issue
Block a user