MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / test_heavy

Method test_heavy

extern/libcds/test/unit/queue/fcqueue.cpp:117–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115
116 template <class Queue>
117 void test_heavy( Queue& q )
118 {
119 typedef typename Queue::value_type value_type;
120 value_type it;
121
122 const int nSize = 100;
123
124 ASSERT_TRUE( q.empty());
125 ASSERT_EQ( q.size(), 0u );
126
127 // enqueue/dequeue
128 for ( int i = 0; i < nSize; ++i ) {
129 ASSERT_TRUE( q.enqueue( value_type( i )));
130 ASSERT_EQ( q.size(), static_cast<size_t>( i + 1 ));
131 }
132 ASSERT_FALSE( q.empty());
133 ASSERT_EQ( q.size(), static_cast<size_t>( nSize ));
134
135 for ( int i = 0; i < nSize; ++i ) {
136 it.value = -1;
137 ASSERT_TRUE( q.dequeue( it ));
138 ASSERT_EQ( it.value, i );
139 ASSERT_EQ( q.size(), static_cast<size_t>( nSize - i - 1 ));
140 }
141 ASSERT_TRUE( q.empty());
142 ASSERT_EQ( q.size(), 0u );
143
144 // push/pop
145 for ( int i = 0; i < nSize; ++i ) {
146 ASSERT_TRUE( q.push( value_type( i )));
147 ASSERT_EQ( q.size(), static_cast<size_t>( i + 1 ));
148 }
149 ASSERT_FALSE( q.empty());
150 ASSERT_EQ( q.size(), static_cast<size_t>( nSize ));
151
152 for ( int i = 0; i < nSize; ++i ) {
153 it.value = -1;
154 ASSERT_TRUE( q.pop( it ));
155 ASSERT_EQ( it.value, i );
156 ASSERT_EQ( q.size(), static_cast<size_t>( nSize - i - 1 ));
157 }
158 ASSERT_TRUE( q.empty());
159 ASSERT_EQ( q.size(), 0u );
160
161 // clear
162 for ( int i = 0; i < nSize; ++i ) {
163 ASSERT_TRUE( q.push( value_type( i )));
164 }
165 ASSERT_FALSE( q.empty());
166 ASSERT_EQ( q.size(), static_cast<size_t>( nSize ));
167
168 q.clear();
169 ASSERT_TRUE( q.empty());
170 ASSERT_EQ( q.size(), 0u );
171
172 // pop from empty queue
173 it = value_type( nSize * 2 );
174 ASSERT_FALSE( q.pop( it ));

Callers

nothing calls this directly

Calls 8

value_typeClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
enqueueMethod · 0.45
dequeueMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected