1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // REQUIRES: has-unix-headers 10 // UNSUPPORTED: c++03 11 // UNSUPPORTED: !libcpp-hardening-mode=debug 12 // XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing 13 14 // <filesystem> 15 16 // class path 17 18 #include <filesystem> 19 #include <iterator> 20 #include <type_traits> 21 #include <cassert> 22 23 #include "check_assertion.h" 24 namespace fs = std::filesystem; 25 main(int,char **)26int main(int, char**) { 27 // Test incrementing/decrementing a singular iterator 28 { 29 fs::path::iterator singular; 30 TEST_LIBCPP_ASSERT_FAILURE(++singular, "attempting to increment a singular iterator"); 31 TEST_LIBCPP_ASSERT_FAILURE(--singular, "attempting to decrement a singular iterator"); 32 } 33 34 // Test incrementing the end iterator 35 { 36 fs::path p("foo/bar"); 37 auto it = p.begin(); 38 TEST_LIBCPP_ASSERT_FAILURE(--it, "attempting to decrement the begin iterator"); 39 } 40 41 // Test incrementing the end iterator 42 { 43 fs::path p("foo/bar"); 44 auto it = p.end(); 45 TEST_LIBCPP_ASSERT_FAILURE(++it, "attempting to increment the end iterator"); 46 } 47 48 return 0; 49 } 50