mirror of
https://github.com/cesanta/slre.git
synced 2024-11-24 03:15:30 +00:00
Add unit test
This commit is contained in:
parent
deb7c0dddf
commit
15b7ff90f8
12
unit_test.c
12
unit_test.c
@ -260,12 +260,14 @@ int main(void) {
|
||||
|
||||
{
|
||||
/* Example more complex regular expression */
|
||||
static const char * str = "aa 1234 xy\nz";
|
||||
static const char * regex = "aa ([0-9]*) *([x-z]*)";
|
||||
struct slre_cap caps[2];
|
||||
ASSERT(slre_match(regex, str, strlen(str), caps, 2, 0) > 0);
|
||||
static const char * str = "aa 1234 xy\nxyz";
|
||||
static const char * regex = "aa ([0-9]*) *([x-z]*)\\s+xy([yz])";
|
||||
struct slre_cap caps[3];
|
||||
ASSERT(slre_match(regex, str, strlen(str), caps, 3, 0) > 0);
|
||||
ASSERT(caps[0].len == 4);
|
||||
ASSERT(caps[1].len == 2); /* Fails here */
|
||||
ASSERT(caps[1].len == 2);
|
||||
ASSERT(caps[2].len == 1);
|
||||
ASSERT(caps[2].ptr[0] == 'z');
|
||||
}
|
||||
|
||||
printf("Unit test %s (total test: %d, failed tests: %d)\n",
|
||||
|
Loading…
Reference in New Issue
Block a user