• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //   Copyright (c) 2013 Alex Korobka
2 //
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 
6 // This test checks whether #8970 was fixed
7 
8 #include <boost/config/warning_disable.hpp>
9 #include <boost/detail/lightweight_test.hpp>
10 #include <iostream>
11 #include <boost/spirit/include/karma.hpp>
12 
13 #include "test.hpp"
14 
15 using namespace spirit_test;
16 using namespace boost::spirit;
17 
18 template <typename Num>
19 struct signed_policy : karma::real_policies<Num>
20 {
force_signsigned_policy21     static bool force_sign(Num /*n*/) { return true; }
22 };
23 
main()24 int main()
25 {
26     karma::real_generator<double, signed_policy<double> > const force_sign_double =
27         karma::real_generator<double, signed_policy<double> >();
28 
29     BOOST_TEST(test("-0.123", force_sign_double, -0.123));
30     BOOST_TEST(test("-1.123", force_sign_double, -1.123));
31     BOOST_TEST(test("0.0", force_sign_double, 0));
32     BOOST_TEST(test("+0.123", force_sign_double, 0.123));
33     BOOST_TEST(test("+1.123", force_sign_double, 1.123));
34 
35     using karma::double_;
36     BOOST_TEST(test("-0.123", double_, -0.123));
37     BOOST_TEST(test("-1.123", double_, -1.123));
38     BOOST_TEST(test("0.0", double_, 0));
39     BOOST_TEST(test("0.123", double_, 0.123));
40     BOOST_TEST(test("1.123", double_, 1.123));
41 
42     return boost::report_errors();
43 }
44