diff options
author | David Robillard <d@drobilla.net> | 2016-12-04 18:49:56 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-12-04 18:49:56 -0500 |
commit | 5ab2e34b2ca6f537d44d23937a527c6d5f0e4dbf (patch) | |
tree | c8ba31572668aea03c5998ebbec724b229596053 | |
parent | 9a848d5ba66b080b8d8c324e3c9a6917a5c36751 (diff) |
Update evoral test suite
-rw-r--r-- | libs/evoral/test/NoteTest.cpp | 33 | ||||
-rw-r--r-- | libs/evoral/test/NoteTest.hpp | 16 | ||||
-rw-r--r-- | libs/evoral/test/SMFTest.cpp | 16 |
3 files changed, 65 insertions, 0 deletions
diff --git a/libs/evoral/test/NoteTest.cpp b/libs/evoral/test/NoteTest.cpp new file mode 100644 index 0000000000..b96cd7c351 --- /dev/null +++ b/libs/evoral/test/NoteTest.cpp @@ -0,0 +1,33 @@ +#include "NoteTest.hpp" +#include "evoral/Note.hpp" +#include "evoral/Beats.hpp" +#include <stdlib.h> + +CPPUNIT_TEST_SUITE_REGISTRATION (NoteTest); + +using namespace Evoral; + +typedef Beats Time; + +void +NoteTest::copyTest () +{ + Note<Time> a(0, Beats(1.0), Beats(2.0), 60, 0x40); + Note<Time> b(a); + CPPUNIT_ASSERT (a == b); + + // Broken due to event double free! + // Note<Time> c(1, Beats(3.0), Beats(4.0), 61, 0x41); + // c = a; + // CPPUNIT_ASSERT (a == c); +} + +void +NoteTest::idTest () +{ + Note<Time> a(0, Beats(1.0), Beats(2.0), 60, 0x40); + CPPUNIT_ASSERT_EQUAL (-1, a.id()); + + a.set_id(1234); + CPPUNIT_ASSERT_EQUAL (1234, a.id()); +} diff --git a/libs/evoral/test/NoteTest.hpp b/libs/evoral/test/NoteTest.hpp new file mode 100644 index 0000000000..9d0af69022 --- /dev/null +++ b/libs/evoral/test/NoteTest.hpp @@ -0,0 +1,16 @@ +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> + +class NoteTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (NoteTest); + CPPUNIT_TEST (copyTest); + CPPUNIT_TEST (idTest); + CPPUNIT_TEST_SUITE_END (); + +public: + void copyTest (); + void idTest (); +}; + + diff --git a/libs/evoral/test/SMFTest.cpp b/libs/evoral/test/SMFTest.cpp index c7e6d23561..b177ca9108 100644 --- a/libs/evoral/test/SMFTest.cpp +++ b/libs/evoral/test/SMFTest.cpp @@ -72,6 +72,22 @@ SMFTest::takeFiveTest () seq->end_write (Sequence<Time>::Relax, Evoral::Beats::ticks_at_rate(time, smf.ppqn())); CPPUNIT_ASSERT(!seq->empty()); + + // Iterate over all notes + bool on = true; + size_t num_notes = 0; + size_t num_sysexes = 0; + for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats()); i != seq->end(); ++i) { + if (i->is_note_on()) { + ++num_notes; + } else if (i->is_sysex()) { + ++num_sysexes; + } + } + CPPUNIT_ASSERT_EQUAL(size_t(3833), seq->notes().size()); + CPPUNIT_ASSERT_EQUAL(size_t(3833), num_notes); + CPPUNIT_ASSERT_EQUAL(size_t(232), seq->sysexes().size()); + CPPUNIT_ASSERT_EQUAL(size_t(232), num_sysexes); } void |