testUniqueObject.cc
Go to the documentation of this file.
1 
11 #include <utl/Test.h>
12 #include <utl/UniqueObject.h>
13 
14 #include <cppunit/extensions/HelperMacros.h>
15 
16 using namespace tst;
17 
18 
19 namespace ns {
20 
21  class Uniq : private utl::UniqueObject<Uniq> {
22  public:
24  };
25 
26 }
27 
28 
32 class testUniqueObject : public CppUnit::TestFixture {
33 
34  CPPUNIT_TEST_SUITE(testUniqueObject);
35  CPPUNIT_TEST(testThrow1);
36  CPPUNIT_TEST(testThrow2);
37  CPPUNIT_TEST(testNoThrow1);
38  CPPUNIT_TEST(testNoThrow2);
39  CPPUNIT_TEST_SUITE_END();
40 
41 public:
42  void setUp() { }
43 
44  void tearDown() { }
45 
46  void
48  {
49  Expected();
50  bool hasThrown = false;
51  try {
52  const ns::Uniq u1;
53  const ns::Uniq u2;
54  } catch (utl::InitSequenceException& ex) {
55  hasThrown = true;
57  }
58  CPPUNIT_ASSERT(hasThrown);
59  }
60 
61  void
63  {
64  Expected();
65  bool hasThrown = false;
66  try {
67  const ns::Uniq u1;
68  testNoThrow2();
69  const ns::Uniq u2;
70  } catch (utl::InitSequenceException& ex) {
71  hasThrown = true;
73  }
74  CPPUNIT_ASSERT(hasThrown);
75  }
76 
77  void
79  {
80  const ns::Uniq u;
81  }
82 
83  void
85  {
86  {
87  const ns::Uniq u;
88  }
89  testNoThrow1();
90  const ns::Uniq u;
91  }
92 
93 };
94 
96 
97 
98 // Configure (x)emacs for this file ...
99 // Local Variables:
100 // mode: c++
101 // End:
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
Exception to use if sequence of initialisations violated.
const double ns
void Expected()
Print `Expected&#39; for expected failures.
Definition: Verify.h:85
Curiously Recurring Template Pattern (CRTP) for unique object.
Definition: UniqueObject.h:27
static void Reset()
static void Reset()
Definition: UniqueObject.h:47

, generated on Tue Sep 26 2023.