Added rm *.log in tests make distclean.
* Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: test.h,v 1.8 2006-07-07 06:59:49 adam Exp $
+ * $Id: test.h,v 1.9 2006-07-07 13:39:02 heikki Exp $
*/
/** \file test.h
} \
}
+/** \brief a test we know will fail at this time.
+ *
+ * Later, when the bug is fixed, this test will suddenly pass,
+ * which will be reported as an error, to remind you to go and fix
+ * your tests.
+ */
+
+#define YAZ_CHECK_TODO(as) { \
+ yaz_check_inc_todo(); \
+ if (!as) { \
+ yaz_check_print1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, "TODO: " #as); \
+ } else { \
+ yaz_check_print1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, "TODO: "#as); \
+ } \
+}
+
/** \brief equality test. left, right only evaluated once */
#define YAZ_CHECK_EQ(left, right) { \
int lval = left; \
YAZ_EXPORT void yaz_check_eq1(int type, const char *file, int line,
const char *left, const char *right,
int lval, int rval);
+/** \brief used by macro. Should not be called directly */
+YAZ_EXPORT void yaz_check_inc_todo(void);
YAZ_END_CDECL
#endif
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: test.c,v 1.9 2006-07-07 06:59:49 adam Exp $
+ * $Id: test.c,v 1.10 2006-07-07 13:39:04 heikki Exp $
*/
/** \file test.c
static FILE *test_fout = 0; /* can't use '= stdout' on some systems */
static int test_total = 0;
static int test_failed = 0;
+static int test_todo = 0;
static int test_verbose = 1;
static const char *test_prog = 0;
static int log_tests = 0;
char logfilename[2048];
log_tests = 1;
sprintf(logfilename,"%s.log", progname(argv0) );
- unlink(logfilename);
yaz_log_init_file(logfilename);
yaz_log_trunc();
}
+void yaz_check_inc_todo(void)
+{
+ test_todo++;
+}
+
void yaz_check_term1(void)
{
/* summary */
if (test_failed)
{
- if (test_verbose >= 1)
- fprintf(get_file(), "%d out of %d tests failed for program %s\n",
+ if (test_verbose >= 1) {
+ if (test_todo)
+ fprintf(get_file(), "%d out of %d tests failed for program %s"
+ " (%d TODO's remaining)\n",
+ test_failed, test_total, test_prog,test_todo);
+ else
+ fprintf(get_file(), "%d out of %d tests failed for program %s\n",
test_failed, test_total, test_prog);
+ }
}
else
{
- if (test_verbose >= 2)
- fprintf(get_file(), "%d tests passed for program %s\n",
+ if (test_verbose >= 2) {
+ if (test_todo)
+ fprintf(get_file(), "%d tests passed for program %s"
+ " (%d TODO's remaining)\n",
+ test_total, test_prog,test_todo);
+ else
+ fprintf(get_file(), "%d tests passed for program %s\n",
test_total, test_prog);
+ }
}
if (test_fout)
fclose(test_fout);
if (log_tests)
{
yaz_log(YLOG_LOG, "%s:%d %s: ", file, line, msg);
- yaz_log(YLOG_LOG, "%s\n", expr);
+ yaz_log(YLOG_LOG, "%s", expr);
}
}
## Copyright (C) 1994-2006, Index Data ApS
## All rights reserved.
-## $Id: Makefile.am,v 1.22 2006-07-05 14:45:57 adam Exp $
+## $Id: Makefile.am,v 1.23 2006-07-07 13:39:05 heikki Exp $
check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl tstlog \
tstsoap1 tstsoap2 tstodrstack tstlogthread tstxmlquery tstpquery \
LDADD = ../src/libyaz.la
+CONFIG_CLEAN_FILES=*.log
+
tsticonv_SOURCES = tsticonv.c
tstnmem_SOURCES = tstnmem.c
tstmatchstr_SOURCES = tstmatchstr.c
/* Copyright (C) 2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: nfaxmltest1.c,v 1.5 2006-07-07 07:14:30 adam Exp $
+ * $Id: nfaxmltest1.c,v 1.6 2006-07-07 13:39:05 heikki Exp $
*
*/
/** \brief Test parsing of a minimal, valid xml string */
void test1() {
- char *xmlstr="<ruleset> "
- "<rule> "
- " <fromstring>foo</fromstring> "
- " <tostring>bar</tostring> "
- "</rule>"
- "</ruleset>";
- yaz_nfa *nfa=yaz_nfa_parse_xml_memory(xmlstr);
-#if 0
-/* doesn't parse */
- YAZ_CHECK(nfa);
-#endif
+ char *xmlstr = "<ruleset> "
+ "<rule> "
+ " <fromstring>foo</fromstring> "
+ " <tostring>bar</tostring> "
+ "</rule>"
+ "</ruleset>";
+ yaz_nfa *nfa = yaz_nfa_parse_xml_memory(xmlstr);
+ YAZ_CHECK_TODO(nfa);
}
-
/** \brief Test parsing of a minimal, invalid xml string */
void test2() {
yaz_nfa *nfa;
- char *xmlstr="<ruleset> "
- "<rule> "
- " <fromstring>foo</fromstring> "
- " <tostring>bar</tostring> "
- "</rule>";
+ char *xmlstr = "<ruleset> "
+ "<rule> "
+ " <fromstring>foo</fromstring> "
+ " <tostring>bar</tostring> "
+ "</rule>";
/* missing "</ruleset>" */
yaz_log(YLOG_LOG,"Parsing bad xml, expecting errors:");
nfa = yaz_nfa_parse_xml_memory(xmlstr);
YAZ_CHECK(!nfa);
}
+/** \brief Test parsing a few minimal xml files */
+void test3() {
+ char *goodfilenames[] = {
+ "nfaxml-simple.xml",
+ "nfaxml-main.xml", /* x-includes nfaxml-include */
+ 0};
+ char *badfilenames[] = {
+ "nfaxml-missing.xml", /* file not there at all */
+ "nfaxml-badinclude.xml", /* bad xinclude in it */
+ 0};
+ yaz_nfa *nfa;
+ char **f = goodfilenames;
+ do {
+ yaz_log(YLOG_LOG,"Parsing (good) xml file '%s'", *f);
+ nfa=yaz_nfa_parse_xml_file(*f);
+ YAZ_CHECK_TODO(nfa);
+ } while (*++f);
+
+ f = badfilenames;
+ do {
+ yaz_log(YLOG_LOG,"Parsing bad xml file '%s'. Expecting errors", *f);
+ nfa = yaz_nfa_parse_xml_file(*f);
+ YAZ_CHECK(!nfa);
+ } while (*++f);
+}
+
int main(int argc, char **argv)
{
test1();
test2();
+ test3();
nmem_exit ();
YAZ_CHECK_TERM;