Skip to content

Commit 21d1b20

Browse files
authored
Update test_compile.c
1 parent 71eb437 commit 21d1b20

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

tests/test_compile.c

+7-14
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,19 @@ This file tests two bug patterns reported by @DavidKorczynski in https://github.
44
55
*/
66

7-
#include <stdlib.h>
87
#include <assert.h>
8+
#include <stdlib.h> /* for NULL */
99
#include "re.h"
1010

11-
const char* invalid_patterns[] = {
12-
"\\\x01[^\\\xff][^",
13-
"\\\x01[^\\\xff][\\",
14-
};
1511

16-
17-
int main(void)
12+
int main()
1813
{
19-
const size_t npatterns = sizeof(invalid_patterns)/sizeof(*invalid_patterns);
20-
size_t i;
14+
/* Test 1: inverted set without a closing ']' */
15+
assert(re_compile("\\\x01[^\\\xff][^") == NULL);
2116

22-
/* loop through all invalid patterns and assume compilation rejects them (returns NULL) */
23-
for (i = 0U; i < npatterns; ++i)
24-
{
25-
assert(re_compile(invalid_patterns[i]) == NULL);
17+
/* Test 2: set with an incomplete escape sequence and without a closing ']' */
18+
assert(re_compile("\\\x01[^\\\xff][\\") == NULL);
2619

27-
}
2820
return 0;
2921
}
22+

0 commit comments

Comments
 (0)