summaryrefslogtreecommitdiffstats
path: root/tests/midi_ringbuffer_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/midi_ringbuffer_test.cpp')
-rw-r--r--tests/midi_ringbuffer_test.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/midi_ringbuffer_test.cpp b/tests/midi_ringbuffer_test.cpp
new file mode 100644
index 0000000..c8fc508
--- /dev/null
+++ b/tests/midi_ringbuffer_test.cpp
@@ -0,0 +1,40 @@
+#include <iostream>
+#include "raul/MIDIRingBuffer.h"
+
+using namespace std;
+using namespace Raul;
+
+void
+read_write_test(MIDIRingBuffer& rb, unsigned offset)
+{
+ TickTime t;
+ size_t size;
+ char buf[5];
+
+ snprintf(buf, 5, "%d", offset);
+ size = strlen(buf);
+
+ size_t written = rb.write(offset, size, buf);
+ assert(written == size);
+
+ for (size_t i=0; i < 4; ++i)
+ buf[i] = 0;
+
+ rb.read(&t, &size, buf);
+
+ cout << "t=" << t << ", s=" << size << ", b='" << buf << "'" << endl;
+
+}
+
+
+int
+main()
+{
+ MIDIRingBuffer rb(32);
+
+ for (size_t i=0; i < 9999; ++i)
+ read_write_test(rb, i);
+
+ return 0;
+}
+