constants.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2004-2007 Jonathan Turkanis
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5. // See http://www.boost.org/libs/iostreams for documentation.
  6. // Contains the definitions of several constants used by the test program.
  7. #ifndef BOOST_IOSTREAMS_TEST_CONSTANTS_HPP_INCLUDED
  8. #define BOOST_IOSTREAMS_TEST_CONSTANTS_HPP_INCLUDED
  9. #include <string.h>
  10. #include <boost/config.hpp>
  11. namespace boost { namespace iostreams { namespace test {
  12. // Note: openmode could be a class type, so this header must be included
  13. // by just one TU.
  14. const BOOST_IOS::openmode in_mode = BOOST_IOS::in | BOOST_IOS::binary;
  15. const BOOST_IOS::openmode out_mode = BOOST_IOS::out | BOOST_IOS::binary;
  16. // Chunk size for reading or writing in chunks.
  17. const int chunk_size = 59;
  18. // Chunk size for reading or writing in chunks.
  19. const int small_buffer_size = 23;
  20. // Number of times data is repeated in test files.
  21. const int data_reps = 300;
  22. namespace detail {
  23. // Returns string which is used to generate test files.
  24. inline const char* data(char*)
  25. {
  26. static const char* c =
  27. "!\"#$%&'()*+,-./0123456879:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  28. "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\n";
  29. return c;
  30. }
  31. // Returns string which is used to generate test files.
  32. inline const wchar_t* data(wchar_t*)
  33. {
  34. static const wchar_t* c =
  35. L"!\"#$%&'()*+,-./0123456879:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  36. L"[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\n";
  37. return c;
  38. }
  39. } // End namespace detail.
  40. inline const char* narrow_data() { return detail::data((char*)0); }
  41. inline const wchar_t* wide_data() { return detail::data((wchar_t*)0); }
  42. // Length of string returned by data().
  43. inline int data_length()
  44. {
  45. static int len = (int) strlen(narrow_data());
  46. return len;
  47. }
  48. } } } // End namespaces detail, iostreams, boost.
  49. #endif // #ifndef BOOST_IOSTREAMS_TEST_CONSTANTS_HPP_INCLUDED