Ticket #1302: add_as_literal.patch

File add_as_literal.patch, 2.9 KB (added by Shunsuke Sogame <pstade.mb@…>, 15 years ago)

wrap string literals with as_literal

  • iterator_range.cpp

     
    2323#include <boost/test/unit_test.hpp>
    2424#include <iostream>
    2525#include <string>
     26#include <boost/range/as_literal.hpp>
    2627
    2728using namespace boost;
    2829using namespace std;
     
    7980    BOOST_CHECK( rr.equal( r ) );
    8081
    8182    rr  = make_iterator_range( str.begin(), str.begin() + 5 );
    82     BOOST_CHECK( rr == "hello" );
    83     BOOST_CHECK( rr != "hell" );
    84     BOOST_CHECK( rr < "hello dude" );
    85     BOOST_CHECK( "hello" == rr );
    86     BOOST_CHECK( "hell"  != rr );
    87     BOOST_CHECK( ! ("hello dude" < rr ) );
     83    BOOST_CHECK( rr == as_literal("hello") );
     84    BOOST_CHECK( rr != as_literal("hell") );
     85    BOOST_CHECK( rr < as_literal("hello dude") );
     86    BOOST_CHECK( as_literal("hello") == rr );
     87    BOOST_CHECK( as_literal("hell")  != rr );
     88    BOOST_CHECK( ! (as_literal("hello dude") < rr ) );
    8889    irange rrr = rr;
    8990    BOOST_CHECK( rrr == rr );
    9091    BOOST_CHECK( !( rrr != rr ) );
     
    9697    BOOST_CHECK_EQUAL( cr[1], 'e' );
    9798
    9899    rrr = make_iterator_range( str, 1, -1 );
    99     BOOST_CHECK( rrr == "ello worl" );
     100    BOOST_CHECK( rrr == as_literal("ello worl") );
    100101    rrr = make_iterator_range( rrr, -1, 1 );
    101102    BOOST_CHECK( rrr == str );
    102103
  • sub_range.cpp

     
    2121#include <iostream>
    2222#include <string>
    2323#include <vector>
     24#include <boost/range/as_literal.hpp>
    2425
    2526using namespace boost;
    2627using namespace std;
     
    110111    BOOST_CHECK( rr.equal( r ) );
    111112
    112113    rr  = make_iterator_range( str.begin(), str.begin() + 5 );
    113     BOOST_CHECK( rr == "hello" );
    114     BOOST_CHECK( rr != "hell" );
    115     BOOST_CHECK( rr < "hello dude" );
    116     BOOST_CHECK( "hello" == rr );
    117     BOOST_CHECK( "hell"  != rr );
    118     BOOST_CHECK( ! ("hello dude" < rr ) );
     114    BOOST_CHECK( rr == as_literal("hello") );
     115    BOOST_CHECK( rr != as_literal("hell") );
     116    BOOST_CHECK( rr < as_literal("hello dude") );
     117    BOOST_CHECK( as_literal("hello") == rr );
     118    BOOST_CHECK( as_literal("hell")  != rr );
     119    BOOST_CHECK( ! (as_literal("hello dude") < rr ) );
    119120   
    120121    irange rrr = rr;
    121122    BOOST_CHECK( rrr == rr );
     
    128129    BOOST_CHECK_EQUAL( cr[1], 'e' );
    129130
    130131    rrr = make_iterator_range( str, 1, -1 );
    131     BOOST_CHECK( rrr == "ello worl" );
     132    BOOST_CHECK( rrr == as_literal("ello worl") );
    132133    rrr = make_iterator_range( rrr, -1, 1 );
    133134    BOOST_CHECK( rrr == str );
    134135    rrr.front() = 'H';
     
    134135    rrr.front() = 'H';
    135136    rrr.back()  = 'D';
    136137    rrr[1]      = 'E';
    137     BOOST_CHECK( rrr == "HEllo worlD" );
     138    BOOST_CHECK( rrr == as_literal("HEllo worlD") );
    138139}   
    139140
    140141#include <boost/test/unit_test.hpp>