summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-12-04 15:40:21 -0500
committerDavid Robillard <d@drobilla.net>2016-12-04 15:40:21 -0500
commit14381919388a2be378805a14e22d0bb229b934f7 (patch)
treecefc37ad5af03bf10d9da0c04eedb7bcd303fdca /libs
parent9dbc524060221b8c72c4d5adf7cfb3a9c0423111 (diff)
Improve coverage of evoral tests
Diffstat (limited to 'libs')
-rw-r--r--libs/evoral/test/SMFTest.cpp33
-rw-r--r--libs/evoral/test/SMFTest.hpp2
2 files changed, 35 insertions, 0 deletions
diff --git a/libs/evoral/test/SMFTest.cpp b/libs/evoral/test/SMFTest.cpp
index 108052c98f..c7e6d23561 100644
--- a/libs/evoral/test/SMFTest.cpp
+++ b/libs/evoral/test/SMFTest.cpp
@@ -39,9 +39,14 @@ SMFTest::takeFiveTest ()
TestSMF smf;
string testdata_path;
CPPUNIT_ASSERT (find_file (test_search_path (), "TakeFive.mid", testdata_path));
+ CPPUNIT_ASSERT (SMF::test(testdata_path));
+
smf.open(testdata_path);
CPPUNIT_ASSERT(!smf.is_empty());
+ CPPUNIT_ASSERT_EQUAL((uint16_t)1, smf.num_tracks());
+ CPPUNIT_ASSERT_EQUAL(0, smf.seek_to_track(1));
+
seq->start_write();
smf.seek_to_start();
@@ -68,3 +73,31 @@ SMFTest::takeFiveTest ()
Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
CPPUNIT_ASSERT(!seq->empty());
}
+
+void
+SMFTest::writeTest ()
+{
+ TestSMF smf;
+ string testdata_path;
+ CPPUNIT_ASSERT (find_file (test_search_path (), "TakeFive.mid", testdata_path));
+
+ smf.open(testdata_path);
+ CPPUNIT_ASSERT(!smf.is_empty());
+
+ TestSMF out;
+ const string output_dir_path = PBD::tmp_writable_directory (PACKAGE, "writeTest");
+ const string new_file_path = Glib::build_filename (output_dir_path, "TakeFiveCopy.mid");
+ CPPUNIT_ASSERT_EQUAL (0, out.create(new_file_path, 1, 1920));
+ out.begin_write();
+
+ uint32_t delta_t = 0;
+ uint32_t size = 0;
+ uint8_t* buf = NULL;
+ while (smf.read_event(&delta_t, &size, &buf) >= 0) {
+ out.append_event_delta(delta_t, size, buf, 0);
+ }
+
+ out.end_write(new_file_path);
+
+ // TODO: Check files are actually equivalent
+}
diff --git a/libs/evoral/test/SMFTest.hpp b/libs/evoral/test/SMFTest.hpp
index 94172c62c8..fc58ede935 100644
--- a/libs/evoral/test/SMFTest.hpp
+++ b/libs/evoral/test/SMFTest.hpp
@@ -54,6 +54,7 @@ class SMFTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(SMFTest);
CPPUNIT_TEST(createNewFileTest);
CPPUNIT_TEST(takeFiveTest);
+ CPPUNIT_TEST(writeTest);
CPPUNIT_TEST_SUITE_END();
public:
@@ -73,6 +74,7 @@ public:
void createNewFileTest();
void takeFiveTest();
+ void writeTest();
private:
DummyTypeMap* type_map;