libtests/t-dateparse
libtests/Makefile
cgi/Makefile
+libtests/index.html
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -c $< > $@.new
mv $@.new $@
-CLEANFILES=definitions.h definitions.h.new version-string versionstring.h
+CLEANFILES=definitions.h definitions.h.new version-string versionstring.h \
+ *.gcda *.gcov *.gcno
EXTRA_DIST=trackdb.c trackdb-stub.c
EXTRA_DIST=t-macros-1.tmpl t-macros-2
+CLEANFILES=*.gcda *.gcov *.gcno
+
DISTCLEANFILES=GraphemeBreakTest.txt NormalizationTest.txt \
WordBreakTest.txt
check_date(now, "%H:%M:%S", localtime);
/* This one needs a bodge: */
check_date(now - now % 60, "%H:%M", localtime);
+ /* Reject invalid formats */
+ check_fatal(dateparse("12"));
+ check_fatal(dateparse("12:34:56:23"));
+ /* Reject invalid values */
+ check_fatal(dateparse("25:34"));
+ check_fatal(dateparse("23:61"));
+ check_fatal(dateparse("23:23:62"));
}
TEST(dateparse);
return s;
}
+jmp_buf fatal_env;
+
+void test_exitfn(int rc) {
+ assert(rc != 0);
+ longjmp(fatal_env, rc);
+}
+
static const struct option options[] = {
{ "verbose", no_argument, 0, 'v' },
{ "fail-first", no_argument, 0, 'F' },
#include <netinet/in.h>
#include <sys/un.h>
#include <pcre.h>
+#include <setjmp.h>
#include "mem.h"
#include "log.h"
++tests; \
} while(0)
+#define check_fatal(WHAT) do { \
+ void (*const save_exitfn)(int) attribute((noreturn)) = exitfn; \
+ \
+ exitfn = test_exitfn; \
+ if(setjmp(fatal_env) == 0) { \
+ fprintf(stderr, "Expect an error:\n "); \
+ (void)(WHAT); \
+ fprintf(stderr, "\n%s:%d: %s unexpectedly returned\n", \
+ __FILE__, __LINE__, #WHAT); \
+ count_error(); \
+ } \
+ ++tests; \
+ exitfn = save_exitfn; \
+} while(0)
+
void count_error(void);
const char *format(const char *s);
const char *format_utf32(const uint32_t *s);
const char *do_printf(const char *fmt, ...);
void test_init(int argc, char **argv);
+extern jmp_buf fatal_env;
+void test_exitfn(int) attribute((noreturn));
+
#define TEST(name) \
int main(int argc, char **argv) { \
test_init(argc, argv); \