~ubuntu-branches/ubuntu/trusty/libc++/trusty

« back to all changes in this revision

Viewing changes to libcxx/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-02 19:43:49 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130902194349-top6vl3nq767uhdm
Tags: 1.0~svn189766-1
New snapshot release

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "../../../test_compare.h"
23
23
#include "../../../test_hash.h"
24
24
#include "../../../test_allocator.h"
 
25
#include "../../../min_allocator.h"
25
26
 
26
27
int main()
27
28
{
108
109
 
109
110
        assert(c0.empty());
110
111
    }
 
112
#if __cplusplus >= 201103L
 
113
    {
 
114
        typedef int P;
 
115
        typedef min_allocator<int> A;
 
116
        typedef std::unordered_set<int,
 
117
                                   test_hash<std::hash<int> >,
 
118
                                   test_compare<std::equal_to<int> >,
 
119
                                   A
 
120
                                   > C;
 
121
        P a[] =
 
122
        {
 
123
            P(1),
 
124
            P(2),
 
125
            P(3),
 
126
            P(4),
 
127
            P(1),
 
128
            P(2)
 
129
        };
 
130
        C c0(a, a + sizeof(a)/sizeof(a[0]),
 
131
            7,
 
132
            test_hash<std::hash<int> >(8),
 
133
            test_compare<std::equal_to<int> >(9),
 
134
            A()
 
135
           );
 
136
        C c(std::move(c0), A());
 
137
        assert(c.bucket_count() >= 5);
 
138
        assert(c.size() == 4);
 
139
        assert(c.count(1) == 1);
 
140
        assert(c.count(2) == 1);
 
141
        assert(c.count(3) == 1);
 
142
        assert(c.count(4) == 1);
 
143
        assert(c.hash_function() == test_hash<std::hash<int> >(8));
 
144
        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
 
145
        assert(c.get_allocator() == A());
 
146
        assert(!c.empty());
 
147
        assert(std::distance(c.begin(), c.end()) == c.size());
 
148
        assert(std::distance(c.cbegin(), c.cend()) == c.size());
 
149
        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
 
150
        assert(c.max_load_factor() == 1);
 
151
 
 
152
        assert(c0.empty());
 
153
    }
 
154
#endif
111
155
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
112
156
}