• 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-2015 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., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 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 #include <string>
00036 
00037 #include "ut_types.h"
00038 
00039 class TF_Test
00040 {
00041     typedef void MainFunc();
00042     const char *m_suite;
00043     const char *descr, *idstr;
00044     MainFunc *main;
00045     TF_Test *next;
00046     static TF_Test *first, *last;
00047     static int fails, runs;
00048     static time_t start_time;
00049 
00050     static void alarm_handler(int sig) ABI_NORETURN;
00051 public:
00052     TF_Test(const char *_suite, const char *_descr,
00053             const char *_idstr, MainFunc *_main);
00054     static int run(const char * const *prefixes, const char * suite);
00055     static int run_all(const char * const *prefixes = NULL);
00056     static int run_suite(const char * suite);
00057     static void start(const char *file, int line, const char *condstr);
00058     static void check(bool cond);
00059     static inline bool start_check(const char *file, int line,
00060                    const char *condstr, bool cond)
00061         { start(file, line, condstr); check(cond); return cond; }
00062     static bool start_check_eq(const char *file, int line,
00063                    const char *a, const char *b);
00064     static bool start_check_eq(const char *file, int line, int a, int b);
00066     static void pulse();
00070     static const char* get_test_src_dir();
00071     static bool ensure_test_data(const char* file, std::string & path);
00072 };
00073 
00074 
00075 
00076 #define TFPASS(cond) \
00077     TF_Test::start_check(__FILE__, __LINE__, #cond, (cond))
00078 #define TFPASSEQ(a, b) \
00079     TF_Test::start_check_eq(__FILE__, __LINE__, (a), (b))
00080 
00081 #define TFFAIL(cond) \
00082     TF_Test::start_check(__FILE__, __LINE__, "NOT(" #cond ")", !(cond))
00083 
00084 #define TFTEST_MAIN3(suite, descr, ff, ll)       \
00085     static void _tftest_main_##ll(); \
00086     static TF_Test _tftest_##ll(suite, descr, ff, _tftest_main_##ll);    \
00087     static void _tftest_main_##ll()
00088 #define TFTEST_MAIN2(suite, descr, ff, ll) \
00089     TFTEST_MAIN3(suite, descr, ff, ll)
00090 #define TFTEST_MAIN(descr) \
00091     TFTEST_MAIN2(TFSUITE, descr, __FILE__, __COUNTER__)
00092 
00093 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1