aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/fs/makefile18
-rw-r--r--tests/fs/path/driver.cxx67
-rw-r--r--tests/fs/path/makefile70
-rw-r--r--tests/makefile2
4 files changed, 156 insertions, 1 deletions
diff --git a/tests/fs/makefile b/tests/fs/makefile
new file mode 100644
index 0000000..071c394
--- /dev/null
+++ b/tests/fs/makefile
@@ -0,0 +1,18 @@
+# file : tests/fs/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009 Code Synthesis Tools CC
+# license : MIT; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+tests := path
+
+default := $(out_base)/
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
+
+$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
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");
+}
diff --git a/tests/fs/path/makefile b/tests/fs/path/makefile
new file mode 100644
index 0000000..55bf89d
--- /dev/null
+++ b/tests/fs/path/makefile
@@ -0,0 +1,70 @@
+# file : tests/fs/path/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009 Code Synthesis Tools CC
+# license : MIT; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
+
+cxx_tun := driver.cxx
+
+#
+#
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+cutl.l := $(out_root)/cutl/cutl.l
+cutl.l.cpp-options := $(out_root)/cutl/cutl.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(cxx_obj) $(cutl.l)
+$(cxx_obj) $(cxx_od): $(cutl.l.cpp-options)
+
+
+$(call include-dep,$(cxx_od))
+
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+$(test): $(driver)
+ $(call message,test $<,$<)
+
+
+# Clean.
+#
+$(clean): \
+ $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od))
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/cutl/makefile)
diff --git a/tests/makefile b/tests/makefile
index ffbd8bd..e3873cb 100644
--- a/tests/makefile
+++ b/tests/makefile
@@ -5,7 +5,7 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
-tests := compiler shared-ptr
+tests := compiler fs shared-ptr
default := $(out_base)/
test := $(out_base)/.test