Home | History | Annotate | Download | only in forwardlist.ops
      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 // void unique();
     13 
     14 #include <forward_list>
     15 #include <iterator>
     16 #include <cassert>
     17 
     18 #include "min_allocator.h"
     19 
     20 int main()
     21 {
     22     {
     23         typedef int T;
     24         typedef std::forward_list<T> C;
     25         const T t1[] = {0, 5, 5, 0, 0, 0, 5};
     26         const T t2[] = {0, 5, 0, 5};
     27         C c1(std::begin(t1), std::end(t1));
     28         C c2(std::begin(t2), std::end(t2));
     29         c1.unique();
     30         assert(c1 == c2);
     31     }
     32     {
     33         typedef int T;
     34         typedef std::forward_list<T> C;
     35         const T t1[] = {0, 0, 0, 0};
     36         const T t2[] = {0};
     37         C c1(std::begin(t1), std::end(t1));
     38         C c2(std::begin(t2), std::end(t2));
     39         c1.unique();
     40         assert(c1 == c2);
     41     }
     42     {
     43         typedef int T;
     44         typedef std::forward_list<T> C;
     45         const T t1[] = {5, 5, 5};
     46         const T t2[] = {5};
     47         C c1(std::begin(t1), std::end(t1));
     48         C c2(std::begin(t2), std::end(t2));
     49         c1.unique();
     50         assert(c1 == c2);
     51     }
     52     {
     53         typedef int T;
     54         typedef std::forward_list<T> C;
     55         C c1;
     56         C c2;
     57         c1.unique();
     58         assert(c1 == c2);
     59     }
     60     {
     61         typedef int T;
     62         typedef std::forward_list<T> C;
     63         const T t1[] = {5, 5, 5, 0};
     64         const T t2[] = {5, 0};
     65         C c1(std::begin(t1), std::end(t1));
     66         C c2(std::begin(t2), std::end(t2));
     67         c1.unique();
     68         assert(c1 == c2);
     69     }
     70 #if __cplusplus >= 201103L
     71     {
     72         typedef int T;
     73         typedef std::forward_list<T, min_allocator<T>> C;
     74         const T t1[] = {0, 5, 5, 0, 0, 0, 5};
     75         const T t2[] = {0, 5, 0, 5};
     76         C c1(std::begin(t1), std::end(t1));
     77         C c2(std::begin(t2), std::end(t2));
     78         c1.unique();
     79         assert(c1 == c2);
     80     }
     81     {
     82         typedef int T;
     83         typedef std::forward_list<T, min_allocator<T>> C;
     84         const T t1[] = {0, 0, 0, 0};
     85         const T t2[] = {0};
     86         C c1(std::begin(t1), std::end(t1));
     87         C c2(std::begin(t2), std::end(t2));
     88         c1.unique();
     89         assert(c1 == c2);
     90     }
     91     {
     92         typedef int T;
     93         typedef std::forward_list<T, min_allocator<T>> C;
     94         const T t1[] = {5, 5, 5};
     95         const T t2[] = {5};
     96         C c1(std::begin(t1), std::end(t1));
     97         C c2(std::begin(t2), std::end(t2));
     98         c1.unique();
     99         assert(c1 == c2);
    100     }
    101     {
    102         typedef int T;
    103         typedef std::forward_list<T, min_allocator<T>> C;
    104         C c1;
    105         C c2;
    106         c1.unique();
    107         assert(c1 == c2);
    108     }
    109     {
    110         typedef int T;
    111         typedef std::forward_list<T, min_allocator<T>> C;
    112         const T t1[] = {5, 5, 5, 0};
    113         const T t2[] = {5, 0};
    114         C c1(std::begin(t1), std::end(t1));
    115         C c2(std::begin(t2), std::end(t2));
    116         c1.unique();
    117         assert(c1 == c2);
    118     }
    119 #endif
    120 }
    121