auto_unit_test.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
18 #ifndef HH_SENF_Utils_auto_unit_test_
19 #define HH_SENF_Utils_auto_unit_test_ 1
20 
21 // Custom includes
22 #include <iostream>
23 
24 #include "auto_unit_test.ih"
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 #include <boost/test/auto_unit_test.hpp>
28 #include <boost/test/test_tools.hpp>
29 
59 #define COMPILE_FAIL(n) void n()
60 
68 #define SENF_CHECK_NO_THROW(expr) \
69  BOOST_CHECK_NO_THROW( \
70  try { expr ; } \
71  catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } )
72 
73 #define SENF_REQUIRE_NO_THROW(expr) \
74  BOOST_REQUIRE_NO_THROW( \
75  try { expr ; } \
76  catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } )
77 
78 namespace senf {
79 namespace test {
80 
81  template <class Iterator>
82  typename detail::NoCharIterator<Iterator>::type nocharIterator(Iterator i);
83 
84 }}
85 
96 #define SENF_CHECK_EQUAL_COLLECTIONS(left_begin, left_end, right_begin, right_end) \
97  BOOST_CHECK_EQUAL_COLLECTIONS( \
98  senf::test::nocharIterator(left_begin), senf::test::nocharIterator(left_end), \
99  senf::test::nocharIterator(right_begin), senf::test::nocharIterator(right_end))
100 
110 #define SENF_AUTO_TEST_CASE(name) \
111  void senf_test_body_##name(); \
112  BOOST_AUTO_TEST_CASE(name) \
113  { \
114  try { \
115  senf_test_body_##name(); \
116  } \
117  catch (std::exception & e) { \
118  std::cerr << e.what() << std::endl; \
119  throw; \
120  } \
121  } \
122  void senf_test_body_##name()
123 
124 
125 #ifdef DOXYGEN
126 
132  #define SENF_CHECK_NOT_EQUAL( Left, Rigth)
133 #else
134 #ifdef BOOST_CHECK_NE
135  #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK_NE( Left, Right)
136 #else
137  #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK( Left != Right)
138 #endif
139 #endif
140 
141 #define SENF_RETURN_NO_ROOT_PRIVILEGES(msg) \
142  if (getuid() != 0) { \
143  BOOST_WARN_MESSAGE(false, msg); \
144  BOOST_CHECK(true); \
145  return; \
146  }
147 
148 //-/////////////////////////////////////////////////////////////////////////////////////////////////
149 //#include "auto_unit_test.cci"
150 //#include "auto_unit_test.ct"
151 #include "auto_unit_test.cti"
152 #endif
153 
154 
155 // Local Variables:
156 // mode: c++
157 // fill-column: 100
158 // comment-column: 40
159 // c-file-style: "senf"
160 // indent-tabs-mode: nil
161 // ispell-local-dictionary: "american"
162 // compile-command: "scons -u test"
163 // End:
detail::NoCharIterator< Iterator >::type nocharIterator(Iterator i)