utility.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2011-2011: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. #ifndef BOOST_LIBS_ICL_TEST_CHRONO_UTILITY_HPP_JOFA_20110314
  9. #define BOOST_LIBS_ICL_TEST_CHRONO_UTILITY_HPP_JOFA_20110314
  10. #include <boost/chrono/chrono.hpp>
  11. #include <boost/chrono/chrono_io.hpp>
  12. // In order to perform simple testing with chrono::time_point
  13. // we need to provide a dummy test clock
  14. class Now // A trivial test clock
  15. {
  16. public:
  17. typedef boost::chrono::duration<int> duration;
  18. typedef duration::rep rep;
  19. typedef duration::period periond;
  20. typedef boost::chrono::time_point<Now> time_point;
  21. static time_point now(){ return time_point(); }
  22. };
  23. namespace boost{ namespace chrono {
  24. template <class CharT>
  25. struct clock_string<Now, CharT>
  26. {
  27. static std::basic_string<CharT> name()
  28. {
  29. static const CharT u[] = {'n', 'o', 'w', '_', 'c', 'l','o', 'c', 'k'};
  30. static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
  31. return str;
  32. }
  33. static std::basic_string<CharT> since()
  34. {
  35. const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'n', 'o', 'w'};
  36. const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
  37. return str;
  38. }
  39. };
  40. }} //namespace boost chrono
  41. #endif //BOOST_LIBS_ICL_TEST_CHRONO_UTILITY_HPP_JOFA_20110314