| 18 | |
| 19 | template<class Callback> |
| 20 | void split(const char *Data, size_t Size, Callback callback) { |
| 21 | |
| 22 | using namespace std::literals; |
| 23 | constexpr auto sep="\n~~~\n"sv; |
| 24 | |
| 25 | std::string_view remainder(Data,Size); |
| 26 | for (;;) { |
| 27 | auto pos=remainder.find(sep); |
| 28 | if(pos==std::string_view::npos) { |
| 29 | //not found. use the remainder and exit |
| 30 | callback(remainder); |
| 31 | return; |
| 32 | } else { |
| 33 | //found. invoke callback on the first part, then proceed with the rest. |
| 34 | callback(remainder.substr(0,pos)); |
| 35 | remainder=remainder.substr(pos+sep.size()); |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 41 |
no test coverage detected