]>
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 #undef BOOST_SPIRIT_THREADSAFE
12 #include <boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp>
13 #include <boost/detail/lightweight_test.hpp>
16 using BOOST_SPIRIT_CLASSIC_NS::impl::object_with_id
;
21 typedef object_with_id
<tag1
> class1
;
22 typedef object_with_id
<tag2
> class2
;
27 std::cout
<< "/////////////////////////////////////////////////////////\n";
29 std::cout
<< " object_with_id test (ST)\n";
31 std::cout
<< "/////////////////////////////////////////////////////////\n";
34 class1
*c1o1
= new class1
;
35 class1
*c1o2
= new class1
;
36 class1
*c1o3
= new class1
;
38 // test wether the objects have consecutive numbers
39 BOOST_TEST(c1o1
->get_object_id()==1);
40 BOOST_TEST(c1o2
->get_object_id()==2);
41 BOOST_TEST(c1o3
->get_object_id()==3);
43 // test wether number recycling works
46 BOOST_TEST(c1o3
->get_object_id()==3);
50 BOOST_TEST(c1o2
->get_object_id()==2);
56 BOOST_TEST(c1o3
->get_object_id()==3);
57 BOOST_TEST(c1o2
->get_object_id()==2);
59 // test whether objects of different classes are numbered independently
60 class2
*c2o1
= new class2
;
61 class2
*c2o2
= new class2
;
62 class2
*c2o3
= new class2
;
63 BOOST_TEST(c2o1
->get_object_id()==1);
64 BOOST_TEST(c2o2
->get_object_id()==2);
65 BOOST_TEST(c2o3
->get_object_id()==3);
72 BOOST_TEST(c1o1
->get_object_id()==1);
73 BOOST_TEST(c2o2
->get_object_id()==2);
75 // test wether the copy ctor doesn't copy the id
77 c1o1
= new class1(*c1o2
);
78 BOOST_TEST(c1o1
->get_object_id()==1);
80 // test wether the assignment operator doesn't assign the id
82 BOOST_TEST(c1o1
->get_object_id()==1);
84 return boost::report_errors();