test_class.hpp 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef TEST_CLASS_DWA2002326_HPP
  6. # define TEST_CLASS_DWA2002326_HPP
  7. # include <boost/detail/lightweight_test.hpp>
  8. template <int n = 0>
  9. struct test_class
  10. {
  11. explicit test_class(int x) : x(x), magic(7654321 + n) { ++counter; }
  12. test_class(test_class const& rhs) : x(rhs.x), magic(7654321 + n) { ++counter; }
  13. virtual ~test_class() { BOOST_TEST(magic == 7654321 + n); magic = 6666666; x = 9999; --counter; }
  14. void set(int _x) { BOOST_TEST(magic == 7654321 + n); this->x = _x; }
  15. int value() const { BOOST_TEST(magic == 7654321 + n); return x; }
  16. operator int() const { return x; }
  17. static int count() { return counter; }
  18. int x;
  19. long magic;
  20. static int counter;
  21. private:
  22. void operator=(test_class const&);
  23. };
  24. template <int n>
  25. int test_class<n>::counter;
  26. #endif // TEST_CLASS_DWA2002326_HPP