1c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow// -*- C++ -*-
2c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow//===------------------------ regex_grep.cpp ------------------------------===//
3c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow//
4c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow//                     The LLVM Compiler Infrastructure
5c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow//
6c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow// This file is dual licensed under the MIT and the University of Illinois Open
7c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow// Source Licenses. See LICENSE.TXT for details.
8c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow//
9c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow//===----------------------------------------------------------------------===//
10c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow
11c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow// XFAIL
12c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow
13c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow#include "fuzzing.h"
14c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow#include <cassert>
15c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow#include <cstring> // for strlen
16c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow
17c85f85a56b91ed92bf57600560873cda93e52860Marshall Clowconst char * test_cases[] = {
18c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	"",
19c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	"s",
20c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	"b*c",
21c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	"ba?sf"
22c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	"lka*ea",
23c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	"adsf*kas;lnc441[0-9]1r34525234"
24c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	};
25c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow
26c85f85a56b91ed92bf57600560873cda93e52860Marshall Clowconst size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
27c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow
28c85f85a56b91ed92bf57600560873cda93e52860Marshall Clowint main ()
29c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow{
30c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	for (size_t i = 0; i < k_num_tests; ++i)
31c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow		{
32c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow		const size_t   size = std::strlen(test_cases[i]);
33c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow		const uint8_t *data = (const uint8_t *) test_cases[i];
34c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow		assert(0 == fuzzing::regex_grep(data, size));
35c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow		}
36c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow	return 0;
37c85f85a56b91ed92bf57600560873cda93e52860Marshall Clow}
38