test: rename some stuff; separate cron part tests
This commit is contained in:
parent
adfdca18da
commit
3bf3150b4a
8 changed files with 77 additions and 12 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include "acutest.h"
|
||||
#include "vieter_cron.h"
|
||||
|
||||
void test_not_allowed() {
|
||||
void test_illegal_expressions() {
|
||||
char *expressions[] = {
|
||||
"4 *-7",
|
||||
"4 *-7/4",
|
||||
|
|
@ -33,6 +33,6 @@ void test_not_allowed() {
|
|||
}
|
||||
|
||||
TEST_LIST = {
|
||||
{"not_allowed", test_not_allowed},
|
||||
{"cron illegal expressions", test_illegal_expressions},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
43
test/cron/test_parse_part.c
Normal file
43
test/cron/test_parse_part.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#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}
|
||||
};
|
||||
Reference in a new issue