aboutsummaryrefslogtreecommitdiff
path: root/tests/fs/path/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-09-13 18:41:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-09-13 18:41:38 +0200
commitf0fb6aeab118255266370121db79ab2a2fed88ad (patch)
tree25deca2aaf0ce2cf468f6d1253b075758ddf926e /tests/fs/path/driver.cxx
parent29c8ce737f513766673fd3e57e30233d9fcce159 (diff)
Add the fs::basic_path class
Diffstat (limited to 'tests/fs/path/driver.cxx')
-rw-r--r--tests/fs/path/driver.cxx67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/fs/path/driver.cxx b/tests/fs/path/driver.cxx
new file mode 100644
index 0000000..d758bde
--- /dev/null
+++ b/tests/fs/path/driver.cxx
@@ -0,0 +1,67 @@
+// file : tests/fs/path/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#include <cassert>
+
+#include <cutl/fs/path.hxx>
+
+using namespace cutl::fs;
+
+int
+main ()
+{
+ // Construction.
+ //
+ try
+ {
+ path ("");
+ assert (false);
+ }
+ catch (invalid_path const&)
+ {
+ }
+
+ assert (path ("/").string () == "/");
+ assert (path ("//").string () == "/");
+ assert (path ("\\\\").string () == "/");
+ assert (path ("/\\").string () == "/");
+ assert (path ("C:").string () == "C:");
+ assert (path ("C:\\").string () == "C:");
+ assert (path ("/tmp/foo/").string () == "/tmp/foo");
+ assert (path ("C:\\tmp\\foo\\").string () == "C:\\tmp\\foo");
+
+ // leaf
+ //
+ assert (path ("/").leaf ().string () == "/");
+ assert (path ("C:").leaf ().string () == "C:");
+ assert (path ("/tmp").leaf ().string () == "tmp");
+ assert (path ("C:\\tmp").leaf ().string () == "tmp");
+ assert (path ("//tmp").leaf ().string () == "tmp");
+ assert (path ("C:\\\\tmp").leaf ().string () == "tmp");
+
+ // directory
+ //
+ assert (path ("/").directory ().string () == "/");
+ assert (path ("C:").directory ().string () == "C:");
+ assert (path ("/tmp").directory ().string () == "/");
+ assert (path ("//tmp").directory ().string () == "/");
+ assert (path ("C:\\tmp").directory ().string () == "C:");
+ assert (path ("C:\\\\tmp").directory ().string () == "C:");
+
+ // base
+ //
+ assert (path ("/").base ().string () == "/");
+ assert (path ("C:").base ().string () == "C:");
+ assert (path ("/foo.txt").base ().string () == "/foo");
+ assert (path ("C:\\foo.txt").base ().string () == "C:\\foo");
+ assert (path (".txt").base ().string () == ".txt");
+ assert (path ("/.txt").base ().string () == "/.txt");
+ assert (path ("foo.txt.orig").base ().string () == "foo.txt");
+
+ // operator/
+ //
+ assert ((path ("/") / path ("tmp")).string () == "/tmp");
+ assert ((path ("foo") / path ("bar")).string () == "foo/bar");
+}