diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-28 16:00:16 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-28 16:00:16 +0000 |
| commit | 15137597824b263c875bd427f7d121eae28d45a6 (patch) | |
| tree | cb6dc61e13822c103ece293f875e85dab24823c0 /test/util_test.cc | |
| parent | 4126980a15f4f6bb981d0793bd37483456c5bc79 (diff) | |
Various fixes.
Diffstat (limited to 'test/util_test.cc')
| -rw-r--r-- | test/util_test.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/util_test.cc b/test/util_test.cc index 74a3e920..15f22f57 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -70,3 +70,46 @@ BOOST_AUTO_TEST_CASE (content_kind_test) BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("psa"), dcp::PUBLIC_SERVICE_ANNOUNCEMENT); BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("advertisement"), dcp::ADVERTISEMENT); } + +BOOST_AUTO_TEST_CASE (relative_to_root_test) +{ + { + boost::filesystem::path root = "a"; + root /= "b"; + + boost::filesystem::path file = "a"; + file /= "b"; + file /= "c"; + + boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file); + BOOST_CHECK (rel); + BOOST_CHECK_EQUAL (rel.get(), boost::filesystem::path ("c")); + } + + { + boost::filesystem::path root = "a"; + root /= "b"; + root /= "c"; + + boost::filesystem::path file = "a"; + file /= "b"; + + boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file); + BOOST_CHECK (!rel); + } + + { + boost::filesystem::path root = "a"; + + boost::filesystem::path file = "a"; + file /= "b"; + file /= "c"; + + boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file); + BOOST_CHECK (rel); + + boost::filesystem::path check = "b"; + check /= "c"; + BOOST_CHECK_EQUAL (rel.get(), check); + } +} |
