Home | History | Annotate | Download | only in path.itr
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03
     11 // UNSUPPORTED: libcpp-no-exceptions
     12 
     13 // <experimental/filesystem>
     14 
     15 // class path
     16 
     17 #define _LIBCPP_DEBUG 0
     18 #define _LIBCPP_ASSERT(cond, msg) ((cond) ? ((void)0) : throw 42)
     19 
     20 #include <experimental/filesystem>
     21 #include <iterator>
     22 #include <type_traits>
     23 #include <cassert>
     24 
     25 #include "test_macros.h"
     26 #include "filesystem_test_helper.hpp"
     27 
     28 namespace fs = std::experimental::filesystem;
     29 
     30 int main() {
     31   using namespace fs;
     32   // Test incrementing/decrementing a singular iterator
     33   {
     34     path::iterator singular;
     35     try {
     36       ++singular;
     37       assert(false);
     38     } catch (int) {}
     39     try {
     40       --singular;
     41       assert(false);
     42     } catch (int) {}
     43   }
     44   // Test decrementing the begin iterator
     45   {
     46     path p("foo/bar");
     47     auto it = p.begin();
     48     try {
     49       --it;
     50       assert(false);
     51     } catch (int) {}
     52     ++it;
     53     ++it;
     54     try {
     55       ++it;
     56       assert(false);
     57     } catch (int) {}
     58   }
     59   // Test incrementing the end iterator
     60   {
     61     path p("foo/bar");
     62     auto it = p.end();
     63     try {
     64       ++it;
     65       assert(false);
     66     } catch (int) {}
     67     --it;
     68     --it;
     69     try {
     70       --it;
     71       assert(false);
     72     } catch (int) {}
     73   }
     74 }