2 * This file is part of DisOrder.
3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 /** @file lib/test.c @brief Library tests */
24 long long tests, errors;
27 void count_error(void) {
33 const char *format(const char *s) {
39 while((c = (unsigned char)*s++)) {
40 if(c >= ' ' && c <= '~')
43 sprintf(buf, "\\x%02X", (unsigned)c);
44 dynstr_append_string(&d, buf);
51 const char *format_utf32(const uint32_t *s) {
58 sprintf(buf, " %04lX", (long)c);
59 dynstr_append_string(&d, buf);
65 uint32_t *ucs4parse(const char *s) {
72 dynstr_ucs4_append(&d, strtoul(s, &e, 0));
73 if(errno) fatal(errno, "strtoul (%s)", s);
76 dynstr_ucs4_terminate(&d);
80 const char *do_printf(const char *fmt, ...) {
86 rc = byte_vasprintf(&s, fmt, ap);
95 fail_first = !!getenv("FAIL_FIRST");
113 /* configuration.c */
162 fprintf(stderr, "%lld errors out of %lld tests\n", errors, tests);