summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac16
-rw-r--r--raul/Path.h6
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/path_test.cpp16
5 files changed, 46 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 025d68b..ce16387 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,8 @@
SUBDIRS = raul doc
+if BUILD_TESTS
+SUBDIRS += tests
+endif
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = raul.pc
diff --git a/configure.ac b/configure.ac
index 635c127..6b9302a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,13 @@ AC_CHECK_FUNCS([strdup strerror])
AC_CHECK_HEADER([pthread.h], [],
AC_MSG_ERROR([Raul requires POSIX threads.]))
+# Build unit tests?
+build_unit_tests="no"
+AC_ARG_ENABLE(unit-tests,
+ [AS_HELP_STRING(--enable-unit-tests, [Build unit tests (no) - Developers only])],
+ [build_unit_tests="$enableval"])
+AM_CONDITIONAL(BUILD_TESTS, [test "$build_unit_tests" = "yes"])
+
build_smart_pointers="yes"
AC_ARG_ENABLE(smart_pointers,
[AS_HELP_STRING(--enable-smart_pointers, [Include smart pointers - requires boost (yes)])],
@@ -63,6 +70,7 @@ AM_CONDITIONAL(WITH_LIBLO, [test "$build_liblo" = "yes"])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([raul/Makefile])
+AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([doc/Makefile])
AC_CONFIG_FILES([doc/reference.doxygen])
AC_CONFIG_FILES([raul.pc])
@@ -73,9 +81,11 @@ AC_MSG_RESULT([])
AC_MSG_RESULT([**********************************************************************])
AC_MSG_RESULT([Raul build configuration:])
AC_MSG_RESULT([])
-AC_MSG_RESULT([OSC supprt: $build_liblo])
-AC_MSG_RESULT([RDF supprt: $build_raptor])
-AC_MSG_RESULT([Smart Pointers: $build_smart_pointers])
+AC_MSG_RESULT([Building unit tests: $build_unit_tests])
+AC_MSG_RESULT([])
+AC_MSG_RESULT([OSC supprt: $build_liblo])
+AC_MSG_RESULT([RDF supprt: $build_raptor])
+AC_MSG_RESULT([Smart Pointers: $build_smart_pointers])
AC_MSG_RESULT([**********************************************************************])
AC_MSG_RESULT([])
diff --git a/raul/Path.h b/raul/Path.h
index d4db163..e79e111 100644
--- a/raul/Path.h
+++ b/raul/Path.h
@@ -240,7 +240,11 @@ public:
inline bool is_child_of(const Path& parent) const
{
- return (length() > parent.length() && substr(0, parent.length()) == parent);
+ /*return (length() > parent.length()
+ && substr(0, parent.length()) == parent
+ && (*this)[parent.length()] == '/');*/
+ const string parent_base = parent.base();
+ return (substr(0, parent_base.length()) == parent_base);
}
inline bool is_parent_of(const Path& child) const
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..0732d07
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,8 @@
+if BUILD_TESTS
+
+AM_CXXFLAGS = -I..
+bin_PROGRAMS = path_test
+
+path_test_SOURCES = path_test.cpp
+
+endif
diff --git a/tests/path_test.cpp b/tests/path_test.cpp
new file mode 100644
index 0000000..1620703
--- /dev/null
+++ b/tests/path_test.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+#include <raul/Path.h>
+
+using namespace std;
+
+int
+main()
+{
+ cerr << "1's are good..." << endl << endl;
+
+ cerr << (Path("/").is_parent_of(Path("/foo"))) << endl;
+ cerr << (Path("/foo").is_parent_of(Path("/foo/bar"))) << endl;
+ cerr << !(Path("/foo").is_parent_of(Path("/foo2"))) << endl;
+
+ return 0;
+}