summaryrefslogtreecommitdiffstats
path: root/test/path_test.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-02 14:46:29 +0100
committerDavid Robillard <d@drobilla.net>2021-01-02 14:46:29 +0100
commitbd0214b1da66225f410641692e89e492f668472a (patch)
tree80956f373070734dc14a7f103e5fa21a5baa0b6e /test/path_test.cpp
parent5c263125aeae87dcd4694a4d3a4781bda7247a00 (diff)
downloadraul-bd0214b1da66225f410641692e89e492f668472a.tar.gz
raul-bd0214b1da66225f410641692e89e492f668472a.tar.bz2
raul-bd0214b1da66225f410641692e89e492f668472a.zip
Format all code with clang-format
Diffstat (limited to 'test/path_test.cpp')
-rw-r--r--test/path_test.cpp139
1 files changed, 70 insertions, 69 deletions
diff --git a/test/path_test.cpp b/test/path_test.cpp
index deda557..5681ec1 100644
--- a/test/path_test.cpp
+++ b/test/path_test.cpp
@@ -26,73 +26,74 @@
int
main()
{
- using Path = Raul::Path;
- using Symbol = Raul::Symbol;
-
- assert(Path("/foo/bar").parent() == Path("/foo"));
- assert(Path("/foo").parent() == Path("/"));
- assert(Path("/").parent() == Path("/"));
-
- assert(Path("/").is_parent_of(Path("/foo")));
- assert(Path("/foo").is_parent_of(Path("/foo/bar")));
- assert(!(Path("/foo").is_parent_of(Path("/foo2"))));
- assert(!(Path("/foo").is_parent_of(Path("/foo"))));
-
- assert(Path::lca(Path("/foo"), Path("/foo/bar/baz")) == Path("/"));
- assert(Path::lca(Path("/foo/bar"), Path("/foo/bar/baz")) == Path("/foo"));
- assert(Path::lca(Path("/foo/bar/quux"), Path("/foo/bar/baz")) == Path("/foo/bar"));
-
- assert(!Path::is_valid(""));
- assert(!Path::is_valid("hello"));
- assert(!Path::is_valid("/foo/bar/"));
- assert(!Path::is_valid("/foo//bar"));
- assert(!Path::is_valid("/foo/bar/d*s"));
- assert(Path::is_valid("/"));
- assert(!Path::is_valid("/foo/3foo/bar"));
-
- assert(Path::descendant_comparator(Path("/"), Path("/")));
- assert(Path::descendant_comparator(Path("/"), Path("/foo")));
- assert(Path::descendant_comparator(Path("/foo"), Path("/foo/bar")));
- assert(Path::descendant_comparator(Path("/foo"), Path("/foo")));
- assert(Path::descendant_comparator(Path("/"), Path("/")));
- assert(!Path::descendant_comparator(Path("/baz"), Path("/")));
- assert(!Path::descendant_comparator(Path("/foo"), Path("/bar")));
- assert(!Path::descendant_comparator(Path("/foo/bar"), Path("/foo")));
-
- assert(!Symbol::is_valid(""));
- assert(!Symbol::is_valid("/I/have/slashes"));
- assert(!Symbol::is_valid("!illegalchar"));
- assert(!Symbol::is_valid("0illegalleadingdigit"));
- assert(strcmp(Symbol::symbolify("").c_str(), ""));
-
- assert(Path("/foo").child(Symbol("bar")) == "/foo/bar");
- assert(Path("/foo").child(Path("/bar/baz")) == "/foo/bar/baz");
- assert(Path("/foo").child(Path("/")) == "/foo");
-
- assert(!strcmp(Path("/foo").symbol(), "foo"));
- assert(!strcmp(Path("/foo/bar").symbol(), "bar"));
- assert(!strcmp(Path("/").symbol(), ""));
-
- const Path original(std::string("/foo/bar"));
- assert(original == original);
-
- bool valid = true;
- try {
- Path path("/ends/in/slash/");
- } catch (const Path::BadPath& e) {
- std::cerr << "Caught exception: " << e.what() << std::endl;
- valid = false;
- }
- assert(!valid);
-
- valid = true;
- try {
- Path path(std::string("/has//double/slash"));
- } catch (const Path::BadPath& e) {
- std::cerr << "Caught exception: " << e.what() << std::endl;
- valid = false;
- }
- assert(!valid);
-
- return 0;
+ using Path = Raul::Path;
+ using Symbol = Raul::Symbol;
+
+ assert(Path("/foo/bar").parent() == Path("/foo"));
+ assert(Path("/foo").parent() == Path("/"));
+ assert(Path("/").parent() == Path("/"));
+
+ assert(Path("/").is_parent_of(Path("/foo")));
+ assert(Path("/foo").is_parent_of(Path("/foo/bar")));
+ assert(!(Path("/foo").is_parent_of(Path("/foo2"))));
+ assert(!(Path("/foo").is_parent_of(Path("/foo"))));
+
+ assert(Path::lca(Path("/foo"), Path("/foo/bar/baz")) == Path("/"));
+ assert(Path::lca(Path("/foo/bar"), Path("/foo/bar/baz")) == Path("/foo"));
+ assert(Path::lca(Path("/foo/bar/quux"), Path("/foo/bar/baz")) ==
+ Path("/foo/bar"));
+
+ assert(!Path::is_valid(""));
+ assert(!Path::is_valid("hello"));
+ assert(!Path::is_valid("/foo/bar/"));
+ assert(!Path::is_valid("/foo//bar"));
+ assert(!Path::is_valid("/foo/bar/d*s"));
+ assert(Path::is_valid("/"));
+ assert(!Path::is_valid("/foo/3foo/bar"));
+
+ assert(Path::descendant_comparator(Path("/"), Path("/")));
+ assert(Path::descendant_comparator(Path("/"), Path("/foo")));
+ assert(Path::descendant_comparator(Path("/foo"), Path("/foo/bar")));
+ assert(Path::descendant_comparator(Path("/foo"), Path("/foo")));
+ assert(Path::descendant_comparator(Path("/"), Path("/")));
+ assert(!Path::descendant_comparator(Path("/baz"), Path("/")));
+ assert(!Path::descendant_comparator(Path("/foo"), Path("/bar")));
+ assert(!Path::descendant_comparator(Path("/foo/bar"), Path("/foo")));
+
+ assert(!Symbol::is_valid(""));
+ assert(!Symbol::is_valid("/I/have/slashes"));
+ assert(!Symbol::is_valid("!illegalchar"));
+ assert(!Symbol::is_valid("0illegalleadingdigit"));
+ assert(strcmp(Symbol::symbolify("").c_str(), ""));
+
+ assert(Path("/foo").child(Symbol("bar")) == "/foo/bar");
+ assert(Path("/foo").child(Path("/bar/baz")) == "/foo/bar/baz");
+ assert(Path("/foo").child(Path("/")) == "/foo");
+
+ assert(!strcmp(Path("/foo").symbol(), "foo"));
+ assert(!strcmp(Path("/foo/bar").symbol(), "bar"));
+ assert(!strcmp(Path("/").symbol(), ""));
+
+ const Path original(std::string("/foo/bar"));
+ assert(original == original);
+
+ bool valid = true;
+ try {
+ Path path("/ends/in/slash/");
+ } catch (const Path::BadPath& e) {
+ std::cerr << "Caught exception: " << e.what() << std::endl;
+ valid = false;
+ }
+ assert(!valid);
+
+ valid = true;
+ try {
+ Path path(std::string("/has//double/slash"));
+ } catch (const Path::BadPath& e) {
+ std::cerr << "Caught exception: " << e.what() << std::endl;
+ valid = false;
+ }
+ assert(!valid);
+
+ return 0;
}