3 #include "cppunit/cppunit_proxy.h"
7 class TestStack: public CppUnitMini::TestCase
16 template <class Stack>
17 void test_elimination()
23 template <class Stack>
24 void test_with( Stack& stack)
26 typedef typename Stack::value_type value_type;
29 CPPUNIT_ASSERT( stack.empty() );
31 CPPUNIT_ASSERT( stack.push(1));
32 CPPUNIT_ASSERT( !stack.empty() );
33 CPPUNIT_ASSERT( stack.push(2));
34 CPPUNIT_ASSERT( !stack.empty() );
35 CPPUNIT_ASSERT( stack.push(3));
36 CPPUNIT_ASSERT( !stack.empty() );
38 CPPUNIT_ASSERT( stack.pop(v) );
39 CPPUNIT_ASSERT( v == 3 );
40 CPPUNIT_ASSERT( !stack.empty() );
41 CPPUNIT_ASSERT( stack.pop_with( [&v]( value_type& src ) { v = src; } ));
42 CPPUNIT_ASSERT( v == 2 );
43 CPPUNIT_ASSERT( !stack.empty() );
44 CPPUNIT_ASSERT( stack.pop(v) );
45 CPPUNIT_ASSERT( v == 1 );
46 CPPUNIT_ASSERT( stack.empty() );
48 CPPUNIT_ASSERT( !stack.pop(v) );
49 CPPUNIT_ASSERT( v == 1000 );
50 CPPUNIT_ASSERT( stack.empty() );
52 CPPUNIT_ASSERT( stack.push(10));
53 CPPUNIT_ASSERT( stack.push(20));
54 CPPUNIT_ASSERT( stack.push(30));
55 CPPUNIT_ASSERT( !stack.empty());
57 CPPUNIT_ASSERT( stack.emplace(100));
58 CPPUNIT_ASSERT( stack.pop(v));
59 CPPUNIT_ASSERT( v == 100 );
62 CPPUNIT_ASSERT( stack.empty() );
69 void Treiber_HP_yield();
70 void Treiber_DHP_yield();
71 void Treiber_HP_pause_alloc();
72 void Treiber_DHP_pause_alloc();
74 void Treiber_HP_relaxed();
75 void Treiber_DHP_relaxed();
76 void Treiber_HP_yield_relaxed();
77 void Treiber_DHP_yield_relaxed();
78 void Treiber_HP_pause_alloc_relaxed();
79 void Treiber_DHP_pause_alloc_relaxed();
81 void Elimination_HP();
82 void Elimination_HP_dyn();
83 void Elimination_HP_stat();
84 void Elimination_DHP();
85 void Elimination_DHP_dyn();
86 void Elimination_DHP_stat();
87 void Elimination_HP_yield();
88 void Elimination_DHP_yield();
89 void Elimination_HP_pause_alloc();
90 void Elimination_DHP_pause_alloc();
92 void Elimination_HP_relaxed();
93 void Elimination_DHP_relaxed();
94 void Elimination_HP_yield_relaxed();
95 void Elimination_DHP_yield_relaxed();
96 void Elimination_HP_pause_alloc_relaxed();
97 void Elimination_DHP_pause_alloc_relaxed();
99 CPPUNIT_TEST_SUITE(TestStack);
100 CPPUNIT_TEST(Treiber_HP)
101 CPPUNIT_TEST(Treiber_HP_relaxed)
102 CPPUNIT_TEST(Treiber_DHP)
103 CPPUNIT_TEST(Treiber_DHP_relaxed)
104 CPPUNIT_TEST(Treiber_HP_yield)
105 CPPUNIT_TEST(Treiber_HP_yield_relaxed)
106 CPPUNIT_TEST(Treiber_DHP_yield)
107 CPPUNIT_TEST(Treiber_DHP_yield_relaxed)
108 CPPUNIT_TEST(Treiber_HP_pause_alloc)
109 CPPUNIT_TEST(Treiber_HP_pause_alloc_relaxed)
110 CPPUNIT_TEST(Treiber_DHP_pause_alloc)
111 CPPUNIT_TEST(Treiber_DHP_pause_alloc_relaxed)
113 CPPUNIT_TEST(Elimination_HP)
114 CPPUNIT_TEST(Elimination_HP_dyn)
115 CPPUNIT_TEST(Elimination_HP_stat)
116 CPPUNIT_TEST(Elimination_HP_relaxed)
117 CPPUNIT_TEST(Elimination_DHP)
118 CPPUNIT_TEST(Elimination_DHP_dyn)
119 CPPUNIT_TEST(Elimination_DHP_stat)
120 CPPUNIT_TEST(Elimination_DHP_relaxed)
121 CPPUNIT_TEST(Elimination_HP_yield)
122 CPPUNIT_TEST(Elimination_HP_yield_relaxed)
123 CPPUNIT_TEST(Elimination_DHP_yield)
124 CPPUNIT_TEST(Elimination_DHP_yield_relaxed)
125 CPPUNIT_TEST(Elimination_HP_pause_alloc)
126 CPPUNIT_TEST(Elimination_HP_pause_alloc_relaxed)
127 CPPUNIT_TEST(Elimination_DHP_pause_alloc)
128 CPPUNIT_TEST(Elimination_DHP_pause_alloc_relaxed)
129 CPPUNIT_TEST_SUITE_END();