]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/owi_st_tests.cpp
1 /*=============================================================================
2 Copyright (c) 2002-2003 Martin Wille
3 http://spirit.sourceforge.net/
5 Use, modification and distribution is subject to the Boost Software
6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
11 #if defined(BOOST_BUILD_PCH_ENABLED) && defined(BOOST_SPIRIT_THREADSAFE)
12 # error BOOST_SPIRIT_THREADSAFE has to be undefined for this test
14 #undef BOOST_SPIRIT_THREADSAFE
15 #include <boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp>
17 #include <boost/core/lightweight_test.hpp>
20 using BOOST_SPIRIT_CLASSIC_NS::impl::object_with_id
;
25 typedef object_with_id
<tag1
> class1
;
26 typedef object_with_id
<tag2
> class2
;
31 std::cout
<< "/////////////////////////////////////////////////////////\n";
33 std::cout
<< " object_with_id test (ST)\n";
35 std::cout
<< "/////////////////////////////////////////////////////////\n";
38 class1
*c1o1
= new class1
;
39 class1
*c1o2
= new class1
;
40 class1
*c1o3
= new class1
;
42 // test wether the objects have consecutive numbers
43 BOOST_TEST(c1o1
->get_object_id()==1);
44 BOOST_TEST(c1o2
->get_object_id()==2);
45 BOOST_TEST(c1o3
->get_object_id()==3);
47 // test wether number recycling works
50 BOOST_TEST(c1o3
->get_object_id()==3);
54 BOOST_TEST(c1o2
->get_object_id()==2);
60 BOOST_TEST(c1o3
->get_object_id()==3);
61 BOOST_TEST(c1o2
->get_object_id()==2);
63 // test whether objects of different classes are numbered independently
64 class2
*c2o1
= new class2
;
65 class2
*c2o2
= new class2
;
66 class2
*c2o3
= new class2
;
67 BOOST_TEST(c2o1
->get_object_id()==1);
68 BOOST_TEST(c2o2
->get_object_id()==2);
69 BOOST_TEST(c2o3
->get_object_id()==3);
76 BOOST_TEST(c1o1
->get_object_id()==1);
77 BOOST_TEST(c2o2
->get_object_id()==2);
79 // test wether the copy ctor doesn't copy the id
81 c1o1
= new class1(*c1o2
);
82 BOOST_TEST(c1o1
->get_object_id()==1);
84 // test wether the assignment operator doesn't assign the id
86 BOOST_TEST(c1o1
->get_object_id()==1);
88 return boost::report_errors();