Home | History | Annotate | Download | only in forwardlist.spec
      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 // <forward_list>
     11 
     12 // template <class T, class Allocator>
     13 //     bool operator==(const forward_list<T, Allocator>& x,
     14 //                     const forward_list<T, Allocator>& y);
     15 //
     16 // template <class T, class Allocator>
     17 //     bool operator!=(const forward_list<T, Allocator>& x,
     18 //                     const forward_list<T, Allocator>& y);
     19 
     20 #include <forward_list>
     21 #include <iterator>
     22 #include <algorithm>
     23 #include <cassert>
     24 
     25 #include "min_allocator.h"
     26 
     27 template <class C>
     28 void test(int N, int M)
     29 {
     30     typedef typename C::value_type T;
     31     C c1;
     32     for (int i = 0; i < N; ++i)
     33         c1.push_front(i);
     34     C c2;
     35     for (int i = 0; i < M; ++i)
     36         c2.push_front(i);
     37     if (N == M)
     38         assert(c1 == c2);
     39     else
     40         assert(c1 != c2);
     41     c2 = c1;
     42     assert(c1 == c2);
     43     if (N > 0)
     44     {
     45         c2.front() = N+1;
     46         assert(c1 != c2);
     47     }
     48 }
     49 
     50 int main()
     51 {
     52     for (int i = 0; i < 10; ++i)
     53         for (int j = 0; j < 10; ++j)
     54             test<std::forward_list<int> >(i, j);
     55 #if __cplusplus >= 201103L
     56     for (int i = 0; i < 10; ++i)
     57         for (int j = 0; j < 10; ++j)
     58             test<std::forward_list<int, min_allocator<int>> >(i, j);
     59 #endif
     60 }
     61