summaryrefslogtreecommitdiffstats
path: root/test/path_test.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-01-07 21:27:39 +0000
committerDavid Robillard <d@drobilla.net>2010-01-07 21:27:39 +0000
commit0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95 (patch)
tree4d41dea009f1647519af8df10f114cd7a6165792 /test/path_test.cpp
parent61ac4a41f0aea63f45d7b27be3ef2e0554e93ece (diff)
downloadraul-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/path_test.cpp')
-rw-r--r--test/path_test.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/path_test.cpp b/test/path_test.cpp
new file mode 100644
index 0000000..099b463
--- /dev/null
+++ b/test/path_test.cpp
@@ -0,0 +1,68 @@
+#include <iostream>
+#include <list>
+#include "raul/log.hpp"
+#include "raul/Path.hpp"
+
+using namespace std;
+using namespace Raul;
+
+int
+main()
+{
+#define CHECK(cond) \
+ do { if (!(cond)) { \
+ error << "Test failed: " << (cond) << endl; \
+ return 1; \
+ } } while (0)
+
+ list<string> names;
+ names.push_back("Dry/Wet Balance");
+ names.push_back("foo+1bar(baz)");
+ names.push_back("ThisCRAR");
+ names.push_back("NAME");
+ names.push_back("thing with a bunch of spaces");
+ names.push_back("thing-with-a-bunch-of-dashes");
+ names.push_back("CamelCaseABC");
+ names.push_back("Signal Level [dB]");
+ names.push_back("Gain dB");
+ names.push_back("Dry/Wet Balance");
+ names.push_back("Phaser1 - Similar to CSound's phaser1 by Sean Costello");
+
+ for (list<string>::iterator i = names.begin(); i != names.end(); ++i) {
+ CHECK(Symbol::is_valid(Path::nameify(*i)));
+ CHECK(Symbol::is_valid(Symbol::symbolify(*i)));
+ }
+
+ CHECK(Path("/foo/bar").parent() == Path("/foo"));
+ CHECK(Path("/foo").parent() == Path("/"));
+ CHECK(Path("/").parent() == Path("/"));
+
+ CHECK(Path("/").is_parent_of(Path("/foo")));
+ CHECK(Path("/foo").is_parent_of(Path("/foo/bar")));
+ CHECK(!(Path("/foo").is_parent_of(Path("/foo2"))));
+
+ CHECK(!Path::is_valid(""));
+ CHECK(!Path::is_valid("hello"));
+ CHECK(!Path::is_valid("/foo/bar/"));
+ CHECK(!Path::is_valid("/foo//bar"));
+ CHECK(!Path::is_valid("/foo/bar/d*s"));
+ CHECK(Path::is_valid("/"));
+ CHECK(!Path::is_valid("/foo/3foo/bar"));
+
+ CHECK(Path::descendant_comparator("/", "/foo"));
+ CHECK(Path::descendant_comparator("/foo", "/foo/bar"));
+ CHECK(Path::descendant_comparator("/foo", "/foo"));
+ CHECK(Path::descendant_comparator("/", "/"));
+ CHECK(!Path::descendant_comparator("/baz", "/"));
+ CHECK(!Path::descendant_comparator("/foo", "/bar"));
+ CHECK(!Path::descendant_comparator("/foo/bar", "/foo"));
+
+ CHECK(!Symbol::is_valid(""));
+ CHECK(!Symbol::is_valid("/I/have/slashes"));
+ CHECK(!Symbol::is_valid("!illegalchar"));
+ CHECK(!Symbol::is_valid("0illegalleadingdigit"));
+ CHECK(Symbol::is_valid(Symbol::symbolify("")));
+ CHECK(Symbol::is_valid(Symbol::symbolify("1hello")));
+
+ return 0;
+}