libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

iterator_db.pass.cpp (1630B)


      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 // MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
     14 // MODULES_DEFINES: _LIBCPP_DEBUG=0
     15 
     16 // <filesystem>
     17 
     18 // class path
     19 
     20 #define _LIBCPP_DEBUG 0
     21 #define _LIBCPP_DEBUG_USE_EXCEPTIONS
     22 #include "filesystem_include.hpp"
     23 #include <iterator>
     24 #include <type_traits>
     25 #include <cassert>
     26 
     27 #include "test_macros.h"
     28 #include "filesystem_test_helper.hpp"
     29 
     30 int main() {
     31   using namespace fs;
     32   using ExType = std::__libcpp_debug_exception;
     33   // Test incrementing/decrementing a singular iterator
     34   {
     35     path::iterator singular;
     36     try {
     37       ++singular;
     38       assert(false);
     39     } catch (ExType const&) {}
     40     try {
     41       --singular;
     42       assert(false);
     43     } catch (ExType const&) {}
     44   }
     45   // Test decrementing the begin iterator
     46   {
     47     path p("foo/bar");
     48     auto it = p.begin();
     49     try {
     50       --it;
     51       assert(false);
     52     } catch (ExType const&) {}
     53     ++it;
     54     ++it;
     55     try {
     56       ++it;
     57       assert(false);
     58     } catch (ExType const&) {}
     59   }
     60   // Test incrementing the end iterator
     61   {
     62     path p("foo/bar");
     63     auto it = p.end();
     64     try {
     65       ++it;
     66       assert(false);
     67     } catch (ExType const&) {}
     68     --it;
     69     --it;
     70     try {
     71       --it;
     72       assert(false);
     73     } catch (ExType const&) {}
     74   }
     75 }