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

Method test

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

Source from the content-addressed store, hash-verified

16 protected:
17 template <class Queue>
18 void test( Queue& q )
19 {
20 typedef typename Queue::value_type value_type;
21 value_type it;
22
23 const int nSize = 100;
24
25 ASSERT_TRUE( q.empty());
26 ASSERT_EQ( q.size(), 0u );
27
28 // enqueue/dequeue
29 for ( int i = 0; i < nSize; ++i ) {
30 ASSERT_TRUE( q.enqueue( value_type(i)));
31 ASSERT_EQ( q.size(), static_cast<size_t>(i + 1));
32 }
33 ASSERT_FALSE( q.empty());
34 ASSERT_EQ( q.size(), static_cast<size_t>( nSize ));
35
36 for ( int i = 0; i < nSize; ++i ) {
37 it = value_type( -1 );
38 ASSERT_TRUE( q.dequeue( it ));
39 ASSERT_EQ( it, value_type( i ));
40 ASSERT_EQ( q.size(), static_cast<size_t>( nSize - i - 1 ));
41 }
42 ASSERT_TRUE( q.empty());
43 ASSERT_EQ( q.size(), 0u );
44
45 // push/pop
46 for ( int i = 0; i < nSize; ++i ) {
47 ASSERT_TRUE( q.push( value_type(i)));
48 ASSERT_EQ( q.size(), static_cast<size_t>( i + 1 ));
49 }
50 ASSERT_FALSE( q.empty());
51 ASSERT_EQ( q.size(), static_cast<size_t>( nSize ));
52
53 for ( int i = 0; i < nSize; ++i ) {
54 it = value_type( -1 );
55 ASSERT_TRUE( q.pop( it ));
56 ASSERT_EQ( it, value_type( i ));
57 ASSERT_EQ( q.size(), static_cast<size_t>( nSize - i - 1 ));
58 }
59 ASSERT_TRUE( q.empty());
60 ASSERT_EQ( q.size(), 0u );
61
62 // clear
63 for ( int i = 0; i < nSize; ++i ) {
64 ASSERT_TRUE( q.push( value_type( i )));
65 }
66 ASSERT_FALSE( q.empty());
67 ASSERT_EQ( q.size(), static_cast<size_t>( nSize ));
68
69 q.clear();
70 ASSERT_TRUE( q.empty());
71 ASSERT_EQ( q.size(), 0u );
72
73 // pop from empty queue
74 it = value_type( nSize * 2 );
75 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