diff options
author | David Robillard <d@drobilla.net> | 2010-01-07 21:27:39 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-07 21:27:39 +0000 |
commit | 0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95 (patch) | |
tree | 4d41dea009f1647519af8df10f114cd7a6165792 /test/smf_test.cpp | |
parent | 61ac4a41f0aea63f45d7b27be3ef2e0554e93ece (diff) | |
download | raul-0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95.tar.gz raul-0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95.tar.bz2 raul-0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95.zip |
Move unit testing and coverage framework into autowaf.
Make raul tests return 0 on success, 1 on failure.
Test coverage for Raul.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2368 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test/smf_test.cpp')
-rw-r--r-- | test/smf_test.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/smf_test.cpp b/test/smf_test.cpp new file mode 100644 index 0000000..40465ed --- /dev/null +++ b/test/smf_test.cpp @@ -0,0 +1,62 @@ +#include <iostream> +#include <string> +#include "raul/SMFReader.hpp" +#include "raul/SMFWriter.hpp" + +using namespace std; +using namespace Raul; + + +int +main(int argc, char** argv) +{ + const char* filename = NULL; + + if (argc < 2) { + filename = "./test.mid"; + SMFWriter writer(TimeUnit(TimeUnit::BEATS, 19200)); + writer.start(string(filename), TimeStamp(writer.unit(), 0, 0)); + writer.finish(); + cout << "Wrote " << filename << " with PPQN = " << writer.unit().ppt() << endl; + + } else { + filename = argv[1]; + } + + + SMFReader reader; + bool opened = reader.open(filename); + + if (!opened) { + cerr << "Unable to open SMF file " << filename << endl; + return -1; + } + + cout << "Opened SMF file " << filename << endl; + + cout << "Type: " << reader.type() << endl; + cout << "Num tracks: " << reader.num_tracks() << endl; + cout << "PPQN: " << reader.ppqn() << endl; + + for (unsigned t=1; t <= reader.num_tracks(); ++t) { + cout << "******** Track " << t << " ********" << endl; + reader.seek_to_track(t); + + unsigned char buf[4]; + uint32_t ev_size; + uint32_t ev_delta_time; + while (reader.read_event(4, buf, &ev_size, &ev_delta_time) >= 0) { + + cout << "Event, size = " << ev_size << ", time = " << ev_delta_time; + cout << ":\t"; + cout.flags(ios::hex); + for (uint32_t i=0; i < ev_size; ++i) { + cout << "0x" << (int)buf[i] << " "; + } + cout.flags(ios::dec); + cout << endl; + } + } + + return 0; +} |