value.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // (C) Copyright Eric Niebler 2005.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/test/unit_test.hpp>
  6. #include <boost/accumulators/accumulators.hpp>
  7. #include <boost/accumulators/statistics/stats.hpp>
  8. using namespace boost;
  9. using namespace unit_test;
  10. using namespace accumulators;
  11. namespace my
  12. {
  13. BOOST_PARAMETER_KEYWORD(tag, int_val)
  14. }
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // test_stat
  17. //
  18. void test_stat()
  19. {
  20. int i = 42;
  21. accumulator_set<double, stats<tag::value<int, my::tag::int_val> > > acc2(
  22. my::int_val = i);
  23. int val1 = value<int, my::tag::int_val>(acc2);
  24. int val2 = value_tag<my::tag::int_val>(acc2);
  25. BOOST_CHECK_EQUAL(i, val1);
  26. BOOST_CHECK_EQUAL(i, val2);
  27. }
  28. ///////////////////////////////////////////////////////////////////////////////
  29. // init_unit_test_suite
  30. //
  31. test_suite* init_unit_test_suite( int argc, char* argv[] )
  32. {
  33. test_suite *test = BOOST_TEST_SUITE("value_accumulator test");
  34. test->add(BOOST_TEST_CASE(&test_stat));
  35. return test;
  36. }