summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-16 19:13:07 +0000
committerDavid Robillard <d@drobilla.net>2011-02-16 19:13:07 +0000
commita06317b5de9a23e4c12ad2f918be0f24c1f67149 (patch)
tree4e56df0fac3241c2513907d832aae163f9bda543 /test
parent26bf74b210f27ea6076ff262757eb813955472c2 (diff)
downloadraul-a06317b5de9a23e4c12ad2f918be0f24c1f67149.tar.gz
raul-a06317b5de9a23e4c12ad2f918be0f24c1f67149.tar.bz2
raul-a06317b5de9a23e4c12ad2f918be0f24c1f67149.zip
Tidy up Raul test suite.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2961 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test')
-rw-r--r--test/atomic_test.cpp3
-rw-r--r--test/midi_ringbuffer_test.cpp2
-rw-r--r--test/queue_test.cpp11
-rw-r--r--test/table_test.cpp37
4 files changed, 29 insertions, 24 deletions
diff --git a/test/atomic_test.cpp b/test/atomic_test.cpp
index 6611c91..7aadae9 100644
--- a/test/atomic_test.cpp
+++ b/test/atomic_test.cpp
@@ -1,4 +1,3 @@
-#include <iostream>
#include "raul/AtomicInt.hpp"
#include "raul/AtomicPtr.hpp"
@@ -8,7 +7,7 @@ using namespace Raul;
int
main()
{
- cout << "Well, at least I compiled; that's gotta count for something eh?" << endl;
+ /* TODO: Actually test functionality... */
return 0;
}
diff --git a/test/midi_ringbuffer_test.cpp b/test/midi_ringbuffer_test.cpp
index 19aa82f..fed3ca0 100644
--- a/test/midi_ringbuffer_test.cpp
+++ b/test/midi_ringbuffer_test.cpp
@@ -39,7 +39,7 @@ main()
{
EventRingBuffer rb(32);
- for (size_t i = 0; i < 1000000; ++i)
+ for (size_t i = 0; i < 100000; ++i)
if (read_write_test(rb, i))
return 1;
diff --git a/test/queue_test.cpp b/test/queue_test.cpp
index 329ec60..5c2209b 100644
--- a/test/queue_test.cpp
+++ b/test/queue_test.cpp
@@ -12,9 +12,9 @@
using namespace std;
using namespace Raul;
-static const unsigned NUM_DATA = 10;
-static const unsigned QUEUE_SIZE = 128;
-static const unsigned NUM_WRITERS = 2;
+static const unsigned NUM_DATA = 10;
+static const unsigned QUEUE_SIZE = 128;
+static const unsigned NUM_WRITERS = 2;
static const unsigned PUSHES_PER_ITERATION = 3;
// Data to read/write using actions pumped through the queue
@@ -47,9 +47,6 @@ SRMWQueue<WriteAction> queue(QUEUE_SIZE);
class WriteThread : public Thread {
protected:
void _run() {
- // Wait for everything to get ready
- sleep(1);
-
while (true) {
for (unsigned j=0; j < PUSHES_PER_ITERATION; ++j) {
unsigned i = rand() % NUM_DATA;
@@ -139,8 +136,6 @@ main()
writers[i]->start();
}
- sleep(1);
-
// Read
unsigned count = 0;
for (unsigned i = 0; i < 10000000; ++i) {
diff --git a/test/table_test.cpp b/test/table_test.cpp
index 41d13c2..5d370fd 100644
--- a/test/table_test.cpp
+++ b/test/table_test.cpp
@@ -4,6 +4,8 @@
#include <map>
#include <set>
#include <sys/time.h>
+
+#include "raul/log.hpp"
#include "raul/PathTable.hpp"
#include "raul/Table.hpp"
#include "raul/TableImpl.hpp"
@@ -33,6 +35,12 @@ void benchmark(size_t n);
int
main(int argc, char** argv)
{
+ #define CHECK(cond) \
+ do { if (!(cond)) { \
+ error << "Test failed: " << (cond) << endl; \
+ return 1; \
+ } } while (0)
+
if (argc == 3 && !strcmp(argv[1], "-b")) {
benchmark(atoi(argv[2]));
return 0;
@@ -115,12 +123,12 @@ main(int argc, char** argv)
pt.insert(make_pair("/foo", 'a'));
pt.insert(make_pair("/bar", 'a'));
pt.insert(make_pair("/bar/baz", 'b'));
- pt.insert(make_pair("/bar/bazz/NO", 'c'));
- pt.insert(make_pair("/bar/baz/YEEEAH", 'c'));
- pt.insert(make_pair("/bar/baz/YEEEAH/BOOOEEEEE", 'c'));
+ pt.insert(make_pair("/bar/bazz/ME", 'c'));
+ pt.insert(make_pair("/bar/baz/YOU", 'c'));
+ pt.insert(make_pair("/bar/baz/US", 'c'));
pt.insert(make_pair("/bar/buzz", 'b'));
- pt.insert(make_pair("/bar/buzz/WHAT", 'c'));
- pt.insert(make_pair("/bar/buzz/WHHHhhhhhAT", 'c'));
+ pt.insert(make_pair("/bar/buzz/THEM", 'c'));
+ pt.insert(make_pair("/bar/buzz/ONE", 'c'));
pt.insert(make_pair("/quux", 'a'));
cout << "Paths: " << endl;
@@ -134,11 +142,14 @@ main(int argc, char** argv)
++descendants_begin;
cout << "\nDescendants of " << descendants_begin->first << endl;
- PathTable<char>::const_iterator descendants_end = pt.find_descendants_end(descendants_begin);
-
- for (PathTable<char>::const_iterator i = pt.begin(); i != descendants_end; ++i)
+ PathTable<char>::const_iterator descendants_end =
+ pt.find_descendants_end(descendants_begin);
+ for (PathTable<char>::const_iterator i = descendants_begin;
+ i != descendants_end; ++i) {
cout << i->first << " ";
- cout << endl;
+ CHECK(Path::descendant_comparator(descendants_begin->first, i->first));
+ }
+ cout << endl << endl;
const Path yank_path("/bar");
PathTable<char>::iterator quux = pt.find(yank_path);
@@ -176,17 +187,17 @@ main(int argc, char** argv)
cout << i->first << " ";
cout << endl;
- for (int i = 0; i < 1000; ++i) {
+ for (int i = 0; i < 500; ++i) {
Table<int, int> t;
- size_t table_size = (rand() % 1000) + 1;
+ size_t table_size = (rand() % 500) + 1;
- for (size_t i=0; i < table_size; ++i) {
+ for (size_t i = 0; i < table_size; ++i) {
int val = rand()%100;
t.insert(make_pair(val, ((val + 3) * 17)));
}
- for (size_t i=0; i < table_size; ++i) {
+ for (size_t i = 0; i < table_size; ++i) {
int val = rand()%100;
Table<int, int>::iterator iter = t.find(val);
assert(iter == t.end() || iter->second == (val + 3) * 17);