Ticket #7569: define-struct-inline-msvc-wknd-tests.patch

File define-struct-inline-msvc-wknd-tests.patch, 5.3 KB (added by zeratul976@…, 10 years ago)

Patch to regression tests

  • libs/fusion/test/sequence/define_struct_inline.cpp

     
    2626    )
    2727};
    2828
     29template <typename = int>
     30struct tpl_cls
     31{
     32    BOOST_FUSION_DEFINE_STRUCT_INLINE(
     33        point,
     34        (int, x)
     35        (int, y)
     36    )
     37};
     38
    2939namespace ns
    3040{
    3141    BOOST_FUSION_DEFINE_STRUCT_INLINE(s, (int, m))
     
    3343    BOOST_FUSION_DEFINE_STRUCT_INLINE(empty_struct, )
    3444}
    3545
    36 int
    37 main()
     46template <typename Point>
     47void run_test()
    3848{
    3949    using namespace boost::fusion;
    4050
     
    4858    }
    4959   
    5060    {
    51         BOOST_MPL_ASSERT_NOT((traits::is_view<cls::point>));
    52         cls::point p(123, 456);
     61        BOOST_MPL_ASSERT_NOT((traits::is_view<Point>));
     62        Point p(123, 456);
    5363
    5464        std::cout << at_c<0>(p) << std::endl;
    5565        std::cout << at_c<1>(p) << std::endl;
     
    6070        at_c<1>(p) = 9;
    6171        BOOST_TEST(p == make_vector(6, 9));
    6272
    63         BOOST_STATIC_ASSERT(boost::fusion::result_of::size<cls::point>::value == 2);
    64         BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<cls::point>::value);
     73        BOOST_STATIC_ASSERT(boost::fusion::result_of::size<Point>::value == 2);
     74        BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<Point>::value);
    6575
    6676        BOOST_TEST(front(p) == 6);
    6777        BOOST_TEST(back(p) == 9);
     
    6979
    7080    {
    7181        vector<int, float> v1(4, 2);
    72         cls::point v2(5, 3);
     82        Point v2(5, 3);
    7383        vector<long, double> v3(5, 4);
    7484        BOOST_TEST(v1 < v2);
    7585        BOOST_TEST(v1 <= v2);
     
    8292    }
    8393
    8494    {
    85         // conversion from cls::point to vector
    86         cls::point p(5, 3);
     95        // conversion from Point to vector
     96        Point p(5, 3);
    8797        vector<int, long> v(p);
    8898        v = p;
    8999    }
    90100
    91101    {
    92         // conversion from cls::point to list
    93         cls::point p(5, 3);
     102        // conversion from Point to list
     103        Point p(5, 3);
    94104        list<int, long> l(p);
    95105        l = p;
    96106    }
     
    105115    }
    106116
    107117    {
    108         cls::point p = make_list(5,3);
     118        Point p = make_list(5,3);
    109119        BOOST_TEST(p == make_vector(5,3));
    110120
    111121        p = make_list(3,5);
    112122        BOOST_TEST(p == make_vector(3,5));
    113123    }
     124}
    114125
     126int
     127main()
     128{
     129    run_test<cls::point>();        // test with non-template enclosing class
     130    run_test<tpl_cls<>::point>();  // test with template enclosing class
    115131    return boost::report_errors();
     132
    116133}
    117134
  • libs/fusion/test/sequence/define_tpl_struct_inline.cpp

     
    2727    )
    2828};
    2929
     30template <typename = int>
     31struct tpl_cls
     32{
     33    BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
     34        (X)(Y),
     35        point,
     36        (X, x)
     37        (Y, y)
     38    )
     39};
     40
    3041namespace ns
    3142{
    3243    BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), s, (M, m))
     
    3445    BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), empty_struct, )
    3546}
    3647
    37 int
    38 main()
     48template <typename Point>
     49void run_test()
    3950{
    4051    using namespace boost::fusion;
    4152
    42     typedef cls::point<int, int> point;
    43 
    4453    std::cout << tuple_open('[');
    4554    std::cout << tuple_close(']');
    4655    std::cout << tuple_delimiter(", ");
     
    5160    }
    5261   
    5362    {
    54         BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
    55         point p(123, 456);
     63        BOOST_MPL_ASSERT_NOT((traits::is_view<Point>));
     64        Point p(123, 456);
    5665
    5766        std::cout << at_c<0>(p) << std::endl;
    5867        std::cout << at_c<1>(p) << std::endl;
     
    6372        at_c<1>(p) = 9;
    6473        BOOST_TEST(p == make_vector(6, 9));
    6574
    66         BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 2);
    67         BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
     75        BOOST_STATIC_ASSERT(boost::fusion::result_of::size<Point>::value == 2);
     76        BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<Point>::value);
    6877
    6978        BOOST_TEST(front(p) == 6);
    7079        BOOST_TEST(back(p) == 9);
     
    7281
    7382    {
    7483        vector<int, float> v1(4, 2);
    75         point v2(5, 3);
     84        Point v2(5, 3);
    7685        vector<long, double> v3(5, 4);
    7786        BOOST_TEST(v1 < v2);
    7887        BOOST_TEST(v1 <= v2);
     
    8594    }
    8695
    8796    {
    88         // conversion from point to vector
    89         point p(5, 3);
     97        // conversion from Point to vector
     98        Point p(5, 3);
    9099        vector<int, long> v(p);
    91100        v = p;
    92101    }
    93102
    94103    {
    95         // conversion from point to list
    96         point p(5, 3);
     104        // conversion from Point to list
     105        Point p(5, 3);
    97106        list<int, long> l(p);
    98107        l = p;
    99108    }
     
    109118
    110119
    111120    {
    112         point p = make_list(5,3);
     121        Point p = make_list(5,3);
    113122        BOOST_TEST(p == make_vector(5,3));
    114123
    115124        p = make_list(3,5);
    116125        BOOST_TEST(p == make_vector(3,5));
    117126    }
     127}
    118128
     129int
     130main()
     131{
     132    run_test<cls::point<int, int> >();        // test non-template enclosing class
     133    run_test<tpl_cls<>::point<int, int> >();  // test template enclosing class
     134   
    119135    return boost::report_errors();
    120136}
    121137