Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvtest.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2003 Net Integration Technologies, Inc. 00004 * 00005 * Part of an automated testing framework. You can declare a "test function" 00006 * using WVTEST_MAIN, and call WVPASS and WVFAIL from there. These produce 00007 * formatted data on stdout that can be read by external testrunner scripts. 00008 * 00009 * More than one WVTEST_MAIN is allowed in a single program, and they all 00010 * get run. 00011 */ 00012 #ifndef __WVTEST_H 00013 #define __WVTEST_H 00014 00015 class WvTest 00016 { 00017 typedef void MainFunc(); 00018 const char *idstr; 00019 MainFunc *main; 00020 WvTest *next; 00021 static WvTest *first, *last; 00022 static int fails, runs; 00023 00024 public: 00025 WvTest(const char *_idstr, MainFunc *_main); 00026 static int run_all(const char *prefix = ""); 00027 static void start(const char *file, int line, const char *condstr); 00028 static void check(bool cond); 00029 }; 00030 00031 00032 #define WVPASS(cond) do { \ 00033 WvTest::start(__FILE__, __LINE__, #cond); \ 00034 WvTest::check((cond)); \ 00035 } while (0) 00036 00037 #define WVFAIL(cond) do { \ 00038 WvTest::start(__FILE__, __LINE__, "NOT(" #cond ")"); \ 00039 WvTest::check(!(cond)); \ 00040 } while (0) 00041 00042 #define WVTEST_MAIN3(ff, ll) \ 00043 static void _wvtest_main_##ll(); \ 00044 static WvTest _wvtest_##ll(ff, _wvtest_main_##ll); \ 00045 static void _wvtest_main_##ll 00046 #define WVTEST_MAIN2(ff, ll) WVTEST_MAIN3(ff, ll) 00047 #define WVTEST_MAIN WVTEST_MAIN2(__FILE__, __LINE__) 00048 00049 00050 #endif // __WVTEST_H

Generated on Tue Oct 5 01:09:21 2004 for WvStreams by doxygen 1.3.7