git-svn-id: svn://localhost/ardour2/branches/3.0@12891 d708f5d6-7413-0410-9779-e7cbd77b26cf
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include "filesystem_test.h"
|
|
#include "pbd/file_utils.h"
|
|
#include "pbd/filesystem.h"
|
|
|
|
using namespace std;
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest);
|
|
|
|
void
|
|
FilesystemTest::testPathIsWithin ()
|
|
{
|
|
system ("rm -r foo");
|
|
CPPUNIT_ASSERT (g_mkdir_with_parents ("foo/bar/baz", 0755) == 0);
|
|
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar/baz", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar"));
|
|
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar/baz", "frobozz") == false);
|
|
|
|
int const r = symlink ("bar", "foo/jim");
|
|
CPPUNIT_ASSERT (r == 0);
|
|
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar/baz", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar"));
|
|
|
|
CPPUNIT_ASSERT (PBD::path_is_within ("foo/jim/baz", "frobozz") == false);
|
|
}
|
|
|