update JACK backend to use new inheritance structure for AudioBackend
[ardour.git] / libs / pbd / test / filesystem_test.cc
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include "filesystem_test.h"
4 #include "pbd/file_utils.h"
5
6 using namespace std;
7
8 CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest);
9
10 void
11 FilesystemTest::testPathIsWithin ()
12 {
13         system ("rm -r foo");
14         CPPUNIT_ASSERT (g_mkdir_with_parents ("foo/bar/baz", 0755) == 0);
15
16         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar/baz", "foo/bar/baz"));
17         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
18         CPPUNIT_ASSERT (PBD::path_is_within ("foo", "foo/bar/baz"));
19         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
20         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar"));
21
22         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar/baz", "frobozz") == false);
23
24         int const r = symlink ("bar", "foo/jim");
25         CPPUNIT_ASSERT (r == 0);
26
27         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar/baz", "foo/bar/baz"));
28         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
29         CPPUNIT_ASSERT (PBD::path_is_within ("foo", "foo/bar/baz"));
30         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar/baz"));
31         CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar"));
32
33         CPPUNIT_ASSERT (PBD::path_is_within ("foo/jim/baz", "frobozz") == false);
34 }
35