예제 #1
0
파일: named.cpp 프로젝트: rogiervd/parse_ll
template <class Parser> void check_repeat_a (Parser const & parser) {
    using range::empty; using range::first; using range::drop;
    {
        std::string r ("aa");
        auto result = parse (parser, r);
        BOOST_CHECK (success (result));
        auto o = output (result);
        BOOST_CHECK (!empty (o));
        BOOST_CHECK (!empty (drop (o)));
        BOOST_CHECK (empty (drop (drop (o))));
        BOOST_CHECK_EQUAL (first (o), 'a');
        BOOST_CHECK_EQUAL (first (drop (o)), 'a');
        BOOST_CHECK (empty (rest (result)));
    }
    {
        std::string r ("ab");
        auto result = parse (parser, r);
        BOOST_CHECK (success (result));
        auto o = output (result);
        BOOST_CHECK (!empty (o));
        BOOST_CHECK (empty (drop (o)));
        BOOST_CHECK_EQUAL (first (o), 'a');
        BOOST_CHECK_EQUAL (first (rest (result)), 'b');
    }
    {
        std::string r ("b");
        auto result = parse (parser, r);
        BOOST_CHECK (success (result));
        auto o = output (result);
        BOOST_CHECK (empty (o));
        BOOST_CHECK_EQUAL (first (rest (result)), 'b');
    }
}
    void compare (Distances distances, Reference const & reference_)
{
    auto reference = range::view (reference_);

    while (!empty (reference)) {
        BOOST_CHECK (!empty (distances));
        if (empty (distances))
            return;

        auto d = chop_in_place (distances);
        auto r = chop_in_place (reference);
        BOOST_CHECK_EQUAL (first (d), first (r));
        BOOST_CHECK_EQUAL (second (d), second (r));
    }
    BOOST_CHECK (empty (distances));
}
예제 #3
0
 static void one_step(size_t li, size_t si, size_t & lo, size_t & so, size_t & offset, range R){
  _check_BC <BoundCheck> (N, R.first(),li);
  _check_BC <BoundCheck> (N, (R.last()==-1 ? li : R.last()) -1 ,li);
  lo  = ((R.last()==-1 ? li : R.last()) - R.first() + R.step()-1 )/R.step() ; //  python behaviour
  so  = R.step();  offset = R.first()  ;
 }