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

Method test

extern/libcds/test/unit/queue/test_bounded_queue.h:17–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 protected:
16 template <typename Queue>
17 void test( Queue& q )
18 {
19 typedef typename Queue::value_type value_type;
20 value_type it;
21
22 const size_t nSize = q.capacity();
23
24 ASSERT_TRUE( q.empty());
25 ASSERT_CONTAINER_SIZE( q, 0 );
26
27 // enqueue/dequeue
28 for ( unsigned pass = 0; pass < 3; ++pass ) {
29 for ( size_t i = 0; i < nSize; ++i ) {
30 it = static_cast<value_type>( i );
31 ASSERT_TRUE( q.enqueue( it ));
32 ASSERT_CONTAINER_SIZE( q, i + 1 );
33 }
34 ASSERT_FALSE( q.empty());
35 ASSERT_CONTAINER_SIZE( q, nSize );
36 ASSERT_FALSE( q.enqueue( static_cast<value_type>( nSize ) * 2 ));
37
38 for ( size_t i = 0; i < nSize; ++i ) {
39 it = -1;
40 ASSERT_TRUE( q.dequeue( it ));
41 ASSERT_EQ( it, static_cast<value_type>( i ));
42 ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
43 }
44 ASSERT_TRUE( q.empty());
45 ASSERT_CONTAINER_SIZE( q, 0 );
46 }
47
48 // push/pop
49 for ( unsigned pass = 0; pass < 3; ++pass ) {
50 for ( size_t i = 0; i < nSize; ++i ) {
51 it = static_cast<value_type>( i );
52 ASSERT_TRUE( q.push( it ));
53 ASSERT_CONTAINER_SIZE( q, i + 1 );
54 }
55 ASSERT_FALSE( q.empty());
56 ASSERT_CONTAINER_SIZE( q, nSize );
57
58 for ( size_t i = 0; i < nSize; ++i ) {
59 it = -1;
60 ASSERT_TRUE( q.pop( it ));
61 ASSERT_EQ( it, static_cast<value_type>( i ));
62 ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
63 }
64 ASSERT_TRUE( q.empty());
65 ASSERT_CONTAINER_SIZE( q, 0 );
66 }
67
68 // push/pop with lambda
69 for ( unsigned pass = 0; pass < 3; ++pass ) {
70 for ( size_t i = 0; i < nSize; ++i ) {
71 it = static_cast<value_type>( i );
72 ASSERT_NE( it, -1 );
73 auto f = [&it]( value_type& dest ) { dest = it; it = -1; };
74 if ( i & 1 )

Callers

nothing calls this directly

Calls 11

capacityMethod · 0.45
emptyMethod · 0.45
enqueueMethod · 0.45
dequeueMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
enqueue_withMethod · 0.45
push_withMethod · 0.45
pop_withMethod · 0.45
dequeue_withMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected