libvieter/test/cron/test_parse_part.c

44 lines
913 B
C

#include "acutest.h"
#include "vieter_cron_parse.h"
struct parse_test {
char *part;
uint8_t min;
uint8_t max;
};
void test_illegal_parts() {
struct parse_test parts[] = {
{ "*-7", 0, 23 },
{ "*-7/4", 0, 23 },
{ "7/*", 0, 23 },
{ "/5", 0, 23 },
{ "4~6", 0, 23 },
{ "5/2-5", 0, 23 },
{ "1/2/3", 0, 23 },
{ "*5", 0, 59 },
{ "x", 0, 59 },
{ NULL, 0, 0 }
};
int i = 0;
uint64_t out;
char *s;
while (parts[i].part != NULL) {
// Function modifies string in-place
s = strdup(parts[i].part);
TEST_CHECK_(vieter_cron_expr_parse_part(&out, s, parts[i].min, parts[i].max) != vieter_cron_parse_ok, "%s (%i - %i)", parts[i].part, parts[i].min, parts[i].max);
free(s);
i++;
}
}
TEST_LIST = {
{"cron illegal parts", test_illegal_parts},
{NULL, NULL}
};