libcxx

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

pop_back.pass.cpp (1039B)


      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 // <list>
     11 
     12 // void pop_back();
     13 
     14 #include <list>
     15 #include <cassert>
     16 
     17 #include "test_macros.h"
     18 #include "min_allocator.h"
     19 
     20 int main()
     21 {
     22     {
     23     int a[] = {1, 2, 3};
     24     std::list<int> c(a, a+3);
     25     c.pop_back();
     26     assert(c == std::list<int>(a, a+2));
     27     c.pop_back();
     28     assert(c == std::list<int>(a, a+1));
     29     c.pop_back();
     30     assert(c.empty());
     31     }
     32 #if TEST_STD_VER >= 11
     33     {
     34     int a[] = {1, 2, 3};
     35     std::list<int, min_allocator<int>> c(a, a+3);
     36     c.pop_back();
     37     assert((c == std::list<int, min_allocator<int>>(a, a+2)));
     38     c.pop_back();
     39     assert((c == std::list<int, min_allocator<int>>(a, a+1)));
     40     c.pop_back();
     41     assert(c.empty());
     42     }
     43 #endif
     44 }