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

Method test

extern/libcds/test/unit/stack/test_treiber_stack.h:17–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 protected:
16 template <class Stack>
17 void test( Stack& stack )
18 {
19 typedef typename Stack::value_type value_type;
20 value_type v;
21
22 ASSERT_TRUE( stack.empty());
23
24 ASSERT_TRUE( stack.push( 1 ));
25 ASSERT_TRUE( !stack.empty());
26 ASSERT_TRUE( stack.push( 2 ));
27 ASSERT_TRUE( !stack.empty());
28 ASSERT_TRUE( stack.push( 3 ));
29 ASSERT_TRUE( !stack.empty());
30
31 ASSERT_TRUE( stack.pop( v ));
32 ASSERT_EQ( v, 3 );
33 ASSERT_TRUE( !stack.empty());
34 ASSERT_TRUE( stack.pop_with( [&v]( value_type& src ) { v = src; } ));
35 ASSERT_EQ( v, 2 );
36 ASSERT_TRUE( !stack.empty());
37 ASSERT_TRUE( stack.pop( v ));
38 ASSERT_EQ( v, 1 );
39 ASSERT_TRUE( stack.empty());
40 v = 1000;
41 ASSERT_TRUE( !stack.pop( v ));
42 ASSERT_EQ( v, 1000 );
43 ASSERT_TRUE( stack.empty());
44
45 ASSERT_TRUE( stack.push( 10 ));
46 ASSERT_TRUE( stack.push( 20 ));
47 ASSERT_TRUE( stack.push( 30 ));
48 ASSERT_TRUE( !stack.empty());
49
50 ASSERT_TRUE( stack.emplace( 100 ));
51 ASSERT_TRUE( stack.pop( v ));
52 ASSERT_EQ( v, 100 );
53
54 stack.clear();
55 ASSERT_TRUE( stack.empty());
56
57 Stack::gc::scan();
58 }
59 };
60} // namespace cds_test
61

Callers

nothing calls this directly

Calls 7

scanFunction · 0.85
emptyMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
pop_withMethod · 0.45
emplaceMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected