TypeID_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (TypeID_t)
2 #include "boost/test/tools/output_test_stream.hpp"
3 #include "boost/test/unit_test.hpp"
4 
6 
7 #include <iostream>
8 #include <string>
9 
10 namespace arttest {
11  struct empty {};
12  struct also_empty {};
13 }
14 
15 BOOST_AUTO_TEST_SUITE(TypeID_t)
16 
17 BOOST_AUTO_TEST_CASE(TypeID_equality_val)
18 {
20  art::TypeID id1(typeid(e));
21  art::TypeID id2(typeid(e));
22 
23  BOOST_TEST(!(id1 < id2));
24  BOOST_TEST(!(id2 < id1));
25 
26  BOOST_TEST(id1 == id2);
27 
28  std::string n1(id1.name());
29  std::string n2(id2.name());
30 
31  BOOST_TEST(n1 == n2);
32 }
33 
34 BOOST_AUTO_TEST_CASE(TypeID_copy_val)
35 {
37  art::TypeID id1(typeid(e));
38 
39  art::TypeID id3 = id1;
40  BOOST_TEST(!(id1 < id3));
41  BOOST_TEST(!(id3 < id1));
42 
43  BOOST_TEST(id1 == id3);
44 
45  std::string n1(id1.name());
46  std::string n3(id3.name());
47  BOOST_TEST(n1 == n3);
48 }
49 
51 {
52  art::TypeID id1(typeid(arttest::empty));
53  art::TypeID id2(typeid(arttest::also_empty));
54 
55  boost::test_tools::output_test_stream os;
56 
57  BOOST_TEST(id1 != id2);
58 
59  os << id1;
60  BOOST_TEST(os.is_equal("arttest::empty"));
61 
62  os.clear();
63  os << id2;
64  BOOST_TEST(os.is_equal("arttest::also_empty"));
65 }
66 
67 BOOST_AUTO_TEST_SUITE_END()
std::string string
Definition: nybbler.cc:12
const double e
char const * name() const
Definition: TypeID.cc:42
BOOST_AUTO_TEST_CASE(TypeID_equality_val)
Definition: TypeID_t.cc:17