Пример #1
0
void test1 ( std::experimental::basic_string_view<CharT> sv, size_t n, size_t pos ) {
    try {
        std::experimental::basic_string_view<CharT> sv1 = sv.substr(pos, n);
        const size_t rlen = std::min ( n, sv.size() - pos );
        assert ( sv1.size() == rlen );
        for ( size_t i = 0; i <= rlen; ++i )
            assert ( sv[pos+i] == sv1[i] );
        }
    catch ( const std::out_of_range & ) { assert ( pos > sv.size()); }
}
Пример #2
0
void test1 ( std::experimental::basic_string_view<CharT> sv, size_t n, size_t pos ) {
    if (pos > sv.size()) {
#ifndef TEST_HAS_NO_EXCEPTIONS
        try {
            std::experimental::basic_string_view<CharT> sv1 = sv.substr(pos, n);
            assert(false);
            ((void)sv1);
        } catch (const std::out_of_range&) {
            return;
        } catch (...) {
            assert(false);
        }
#endif
    } else {
        std::experimental::basic_string_view<CharT> sv1 = sv.substr(pos, n);
        const size_t rlen = std::min ( n, sv.size() - pos );
        assert ( sv1.size() == rlen );
        for ( size_t i = 0; i <= rlen; ++i )
            assert ( sv[pos+i] == sv1[i] );
    }
}