• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

tf_test.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiWord
00004  * Copyright (c) 2004,2005 Hubert Figuiere
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 /* Original Copyright notice, as part of WvStreams, LGPL licensed */
00022 /*
00023  * Worldvisions Weaver Software:
00024  *   Copyright (C) 1997-2003 Net Integration Technologies, Inc.
00025  *
00026  * Part of an automated testing framework.  See wvtest.h.
00027  */
00028 
00029 
00030 #ifndef __TF_TEST_H__
00031 #define __TF_TEST_H__
00032 
00033 #include <time.h>
00034 
00035 class TF_Test
00036 {
00037     typedef void MainFunc();
00038     const char *descr, *idstr;
00039     MainFunc *main;
00040     TF_Test *next;
00041     static TF_Test *first, *last;
00042     static int fails, runs;
00043     static time_t start_time;
00044 
00045     static void alarm_handler(int sig);
00046 
00047 public:
00048     TF_Test(const char *_descr, const char *_idstr, MainFunc *_main);
00049     static int run_all(const char * const *prefixes = NULL);
00050     static void start(const char *file, int line, const char *condstr);
00051     static void check(bool cond);
00052     static inline bool start_check(const char *file, int line,
00053                    const char *condstr, bool cond)
00054         { start(file, line, condstr); check(cond); return cond; }
00055     static bool start_check_eq(const char *file, int line,
00056                    const char *a, const char *b);
00057     static bool start_check_eq(const char *file, int line, int a, int b);
00058 };
00059 
00060 
00061 
00062 #define TFPASS(cond) \
00063     TF_Test::start_check(__FILE__, __LINE__, #cond, (cond))
00064 #define TFPASSEQ(a, b) \
00065     TF_Test::start_check_eq(__FILE__, __LINE__, (a), (b))
00066 
00067 #define TFFAIL(cond) \
00068     TF_Test::start_check(__FILE__, __LINE__, "NOT(" #cond ")", !(cond))
00069 
00070 #define TFTEST_MAIN3(descr, ff, ll) \
00071     static void _tftest_main_##ll(); \
00072     static TF_Test _tftest_##ll(descr, ff, _tftest_main_##ll); \
00073     static void _tftest_main_##ll()
00074 #define TFTEST_MAIN2(descr, ff, ll) TFTEST_MAIN3(descr, ff, ll)
00075 #define TFTEST_MAIN(descr) TFTEST_MAIN2(descr, __FILE__, __COUNTER__)
00076 
00077 #endif

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1