test_helpers2.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. //
  8. // NOTE: This file is intended to be used ONLY by the test files
  9. // from the Numeric Conversions Library
  10. //
  11. //
  12. // The following 'to_string' helpers are provided to give readable names
  13. // to the various enums used by the library.
  14. // NOTE: specializations of boost::lexical_cast<> were not used since some compilers had
  15. // trouble dealing with such specializations for different enumerations.
  16. //
  17. std::string to_string ( boost::numeric::int_float_mixture_enum arg )
  18. {
  19. switch ( arg )
  20. {
  21. case boost::numeric::integral_to_integral : return "integral_to_integral" ;
  22. case boost::numeric::integral_to_float : return "integral_to_float" ;
  23. case boost::numeric::float_to_integral : return "float_to_integral" ;
  24. case boost::numeric::float_to_float : return "float_to_float" ;
  25. }
  26. return "(Unknown result!)" ;
  27. }
  28. std::string to_string ( boost::numeric::sign_mixture_enum arg )
  29. {
  30. switch ( arg )
  31. {
  32. case boost::numeric::unsigned_to_unsigned : return "unsigned_to_unsigned" ;
  33. case boost::numeric::signed_to_signed : return "signed_to_signed" ;
  34. case boost::numeric::signed_to_unsigned : return "signed_to_unsigned" ;
  35. case boost::numeric::unsigned_to_signed : return "unsigned_to_signed" ;
  36. }
  37. return "(Unknown result!)" ;
  38. }
  39. std::string to_string ( boost::numeric::udt_builtin_mixture_enum arg )
  40. {
  41. switch ( arg )
  42. {
  43. case boost::numeric::builtin_to_builtin : return "builtin_to_builtin" ;
  44. case boost::numeric::builtin_to_udt : return "builtin_to_udt" ;
  45. case boost::numeric::udt_to_builtin : return "udt_to_builtin" ;
  46. case boost::numeric::udt_to_udt : return "udt_to_udt" ;
  47. }
  48. return "(Unknown result!)" ;
  49. }
  50. //
  51. ///////////////////////////////////////////////////////////////////////////////////////////////