From ec362b39ad0375845e583252c29398e920b97409 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 28 May 2012 16:48:39 +0000 Subject: [PATCH] Missing files. git-svn-id: svn://localhost/ardour2/branches/3.0@12469 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/test/filesystem_test.cc | 35 ++++++++++++++++++++++++++++++++ libs/pbd/test/filesystem_test.h | 14 +++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 libs/pbd/test/filesystem_test.cc create mode 100644 libs/pbd/test/filesystem_test.h diff --git a/libs/pbd/test/filesystem_test.cc b/libs/pbd/test/filesystem_test.cc new file mode 100644 index 0000000000..11371c8cb6 --- /dev/null +++ b/libs/pbd/test/filesystem_test.cc @@ -0,0 +1,35 @@ +#include +#include +#include "filesystem_test.h" +#include "pbd/filesystem.h" + +using namespace std; + +CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest); + +void +FilesystemTest::testPathIsWithin () +{ + system ("rm -r foo"); + PBD::sys::create_directories ("foo/bar/baz"); + + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar/baz", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar", "foo/bar")); + + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar/baz", "frobozz") == false); + + int const r = symlink ("bar", "foo/jim"); + CPPUNIT_ASSERT (r == 0); + + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar/baz", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar", "foo/bar/baz")); + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/bar", "foo/bar")); + + CPPUNIT_ASSERT (PBD::sys::path_is_within ("foo/jim/baz", "frobozz") == false); +} + diff --git a/libs/pbd/test/filesystem_test.h b/libs/pbd/test/filesystem_test.h new file mode 100644 index 0000000000..57f26631d0 --- /dev/null +++ b/libs/pbd/test/filesystem_test.h @@ -0,0 +1,14 @@ +#include +#include + +class FilesystemTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (FilesystemTest); + CPPUNIT_TEST (testPathIsWithin); + CPPUNIT_TEST_SUITE_END (); + +public: + void testPathIsWithin (); + +}; +