| 189 | } // (anon) |
| 190 | |
| 191 | class basic_parser_test |
| 192 | { |
| 193 | public: |
| 194 | ::test_suite::log_type log; |
| 195 | |
| 196 | #ifdef _MSC_VER |
| 197 | #pragma warning(push) |
| 198 | #pragma warning(disable: 4456) // non dll-interface class used as base for dll-interface class |
| 199 | #endif |
| 200 | |
| 201 | #define TEST_GRIND_ONE(s, good, po) \ |
| 202 | do { \ |
| 203 | string_view _test_gr1_s = s; \ |
| 204 | system::error_code ec; \ |
| 205 | fail_parser p((po)); \ |
| 206 | auto sz = p.write(false, _test_gr1_s.data(), _test_gr1_s.size(), ec); \ |
| 207 | if(good) \ |
| 208 | { \ |
| 209 | if(! BOOST_TEST(!ec) ) \ |
| 210 | { \ |
| 211 | log << " " << ec.what() << " after " << sz << " characters of " << _test_gr1_s << '\n'; \ |
| 212 | } \ |
| 213 | } \ |
| 214 | else \ |
| 215 | BOOST_TEST(ec); \ |
| 216 | } while (false) |
| 217 | |
| 218 | #define TEST_GRIND(s, good, po) \ |
| 219 | do { \ |
| 220 | TEST_GRIND_ONE((s), (good), (po)); \ |
| 221 | string_view _test_gr_s = s; \ |
| 222 | /* split/errors matrix*/ \ |
| 223 | if(! _test_gr_s.empty()) \ |
| 224 | { \ |
| 225 | for(std::size_t i = 1; i < _test_gr_s.size(); ++i) \ |
| 226 | { \ |
| 227 | for(std::size_t j = 1;;++j) \ |
| 228 | { \ |
| 229 | system::error_code ec; \ |
| 230 | fail_parser p(j, (po)); \ |
| 231 | auto sz = p.write(true, _test_gr_s.data(), i, ec); \ |
| 232 | if(ec == error::test_failure) \ |
| 233 | continue; \ |
| 234 | if(! ec) \ |
| 235 | { \ |
| 236 | sz += p.write(false, \ |
| 237 | _test_gr_s.data() + i, \ |
| 238 | _test_gr_s.size() - i, \ |
| 239 | ec); \ |
| 240 | if(ec == error::test_failure) \ |
| 241 | continue; \ |
| 242 | } \ |
| 243 | if(good) \ |
| 244 | { \ |
| 245 | if(! BOOST_TEST(!ec) ) \ |
| 246 | { \ |
| 247 | log << " " << ec.what() << " after " << sz << " characters of " << _test_gr_s << '\n'; \ |
| 248 | } \ |