diff options
Diffstat (limited to 'test/libcxx/experimental/filesystem/class.path')
3 files changed, 149 insertions, 0 deletions
diff --git a/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp b/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp new file mode 100644 index 000000000000..a98a9ccd2a80 --- /dev/null +++ b/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: libcpp-no-exceptions + +// <experimental/filesystem> + +// class path + +#define _LIBCPP_DEBUG 0 +#define _LIBCPP_ASSERT(cond, msg) ((cond) ? ((void)0) : throw 42) + +#include <experimental/filesystem> +#include <iterator> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" +#include "filesystem_test_helper.hpp" + +namespace fs = std::experimental::filesystem; + +int main() { + using namespace fs; + // Test incrementing/decrementing a singular iterator + { + path::iterator singular; + try { + ++singular; + assert(false); + } catch (int) {} + try { + --singular; + assert(false); + } catch (int) {} + } + // Test decrementing the begin iterator + { + path p("foo/bar"); + auto it = p.begin(); + try { + --it; + assert(false); + } catch (int) {} + ++it; + ++it; + try { + ++it; + assert(false); + } catch (int) {} + } + // Test incrementing the end iterator + { + path p("foo/bar"); + auto it = p.end(); + try { + ++it; + assert(false); + } catch (int) {} + --it; + --it; + try { + --it; + assert(false); + } catch (int) {} + } +}
\ No newline at end of file diff --git a/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp b/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp new file mode 100644 index 000000000000..c43ea078f989 --- /dev/null +++ b/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <experimental/filesystem> + +// class path + +// path& operator/=(path const&) +// path operator/(path const&, path const&) + + +#define _LIBCPP_DEBUG 0 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++) +int AssertCount = 0; + +#include <experimental/filesystem> +#include <type_traits> +#include <string_view> +#include <cassert> + +#include "test_macros.h" +#include "test_iterators.h" +#include "count_new.hpp" +#include "filesystem_test_helper.hpp" + +namespace fs = std::experimental::filesystem; + +int main() +{ + using namespace fs; + { + path lhs("//foo"); + path rhs("/bar"); + assert(AssertCount == 0); + lhs /= rhs; + assert(AssertCount == 0); + } + { + path lhs("//foo"); + path rhs("/bar"); + assert(AssertCount == 0); + (void)(lhs / rhs); + assert(AssertCount == 0); + } + { + path lhs("//foo"); + path rhs("//bar"); + assert(AssertCount == 0); + lhs /= rhs; + assert(AssertCount == 1); + AssertCount = 0; + } + { + path lhs("//foo"); + path rhs("//bar"); + assert(AssertCount == 0); + (void)(lhs / rhs); + assert(AssertCount == 1); + } + // FIXME The same error is not diagnosed for the append(Source) and + // append(It, It) overloads. +} diff --git a/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp b/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp index 94de2108f8b5..61d322524071 100644 --- a/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp +++ b/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp @@ -28,6 +28,7 @@ #include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" +#include "constexpr_char_traits.hpp" namespace fs = std::experimental::filesystem; @@ -59,6 +60,8 @@ struct MakeTestType { using value_type = CharT; using string_type = std::basic_string<CharT>; using string_type2 = std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>; + using string_view_type = std::basic_string_view<CharT>; + using string_view_type2 = std::basic_string_view<CharT, constexpr_char_traits<CharT>>; using cstr_type = CharT* const; using const_cstr_type = const CharT*; using array_type = CharT[25]; @@ -81,6 +84,8 @@ struct MakeTestType { static void Test() { AssertPathable<string_type>(); AssertPathable<string_type2>(); + AssertPathable<string_view_type>(); + AssertPathable<string_view_type2>(); AssertPathable<cstr_type>(); AssertPathable<const_cstr_type>(); AssertPathable<array_type>(); |
