Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

xtests/xtests.h

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        xtests/xtests.h (formerly part of Synesis' internal test codebase)
00003  *
00004  * Purpose:     Main header file for xTests, a simple unit/component-testing
00005  *              library.
00006  *
00007  * Created:     20th June 1999
00008  * Updated:     1st February 2009
00009  *
00010  * Home:        http://stlsoft.org/
00011  *
00012  * Copyright (c) 1999-2009, Matthew Wilson and Synesis Software
00013  * All rights reserved.
00014  *
00015  * Redistribution and use in source and binary forms, with or without
00016  * modification, are permitted provided that the following conditions are
00017  * met:
00018  *
00019  * - Redistributions of source code must retain the above copyright notice,
00020  *   this list of conditions and the following disclaimer.
00021  * - Redistributions in binary form must reproduce the above copyright
00022  *   notice, this list of conditions and the following disclaimer in the
00023  *   documentation and/or other materials provided with the distribution.
00024  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
00025  *   names of any contributors may be used to endorse or promote products
00026  *   derived from this software without specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00029  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00030  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00031  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00032  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00033  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00034  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00035  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00036  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00037  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00038  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  * ////////////////////////////////////////////////////////////////////// */
00041 
00042 
00048 #ifndef XTESTS_INCL_XTESTS_H_XTESTS
00049 #define XTESTS_INCL_XTESTS_H_XTESTS
00050 
00051 #ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
00052 # define XTESTS_VER_XTESTS_H_XTESTS_MAJOR       3
00053 # define XTESTS_VER_XTESTS_H_XTESTS_MINOR       21
00054 # define XTESTS_VER_XTESTS_H_XTESTS_REVISION    3
00055 # define XTESTS_VER_XTESTS_H_XTESTS_EDIT        273
00056 #endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
00057 
00058 /* /////////////////////////////////////////////////////////////////////////
00059  * Version information
00060  */
00061 
00076 #define _XTESTS_VER_MAJOR       0
00077 #define _XTESTS_VER_MINOR       10
00078 #define _XTESTS_VER_REVISION    3
00079 
00080 #define _XTESTS_VER             0x000a03ff
00081 
00082 /* /////////////////////////////////////////////////////////////////////////
00083  * Includes - 1
00084  */
00085 
00086 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00087 # include <stlsoft/stlsoft.h>
00088 #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
00089 
00090 /* /////////////////////////////////////////////////////////////////////////
00091  * Compatibility
00092  */
00093 
00094 #if _STLSOFT_VER < 0x010948ff
00095 # error xTests requires version 1.9.72 (or later) of STLSoft; download from www.stlsoft.org
00096 #endif /* _STLSOFT_VER */
00097 
00098 #if defined(STLSOFT_COMPILER_IS_WATCOM)
00099 # define _XTESTS_NO_CPP_API
00100 #endif /* compiler */
00101 
00102 /* /////////////////////////////////////////////////////////////////////////
00103  * Includes - 2
00104  */
00105 
00106 #ifdef __cplusplus
00107 # include <platformstl/platformstl.h>
00108 # if defined(PLATFORMSTL_OS_IS_UNIX)
00109  /* We include threading.h to prevent the definition of _REENTRANT standard
00110   * headers on some UNIX operating systems from confusing the feature
00111   * discrimination in UNIXSTL and having it think that we're multithreading
00112   * when we're not.
00113   */
00114 #  include <unixstl/synch/util/features.h>
00115 # elif defined(PLATFORMSTL_OS_IS_WINDOWS)
00116 # endif /* PLATFORMSTL_OS_IS_???? */
00117 # if !defined(_XTESTS_NO_CPP_API)
00118 #  ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_INTEGRAL_TYPE
00119 #   include <stlsoft/meta/is_integral_type.hpp>
00120 #  endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_INTEGRAL_TYPE */
00121 #  ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_SAME_TYPE
00122 #   include <stlsoft/meta/is_same_type.hpp>
00123 #  endif /* !STLSOFT_INCL_STLSOFT_META_HPP_IS_SAME_TYPE */
00124 #  ifndef STLSOFT_INCL_STLSOFT_META_HPP_SELECT_FIRST_TYPE_IF
00125 #   include <stlsoft/meta/select_first_type_if.hpp>
00126 #  endif /* !STLSOFT_INCL_STLSOFT_META_HPP_SELECT_FIRST_TYPE_IF */
00127 #  ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00128 #   include <stlsoft/shims/access/string.hpp>
00129 #  endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING */
00130 # endif /* !_XTESTS_NO_CPP_API */
00131 # if defined(STLSOFT_CF_EXCEPTION_SUPPORT)
00132 #  include <new>
00133 #  include <stdexcept>
00134 # endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
00135 # if defined(STLSOFT_CF_RTTI_SUPPORT)
00136 #  include <typeinfo>
00137 # endif /* STLSOFT_CF_RTTI_SUPPORT */
00138 #endif /* __cplusplus */
00139 
00140 #include <stdio.h>
00141 
00142 /* /////////////////////////////////////////////////////////////////////////
00143  * Namespace
00144  */
00145 
00146 #if defined(_STLSOFT_NO_NAMESPACE)
00147 # define _XTESTS_NO_NAMESPACE
00148 #endif /* _STLSOFT_NO_NAMESPACE */
00149 
00150 #ifndef _XTESTS_NO_NAMESPACE
00151 namespace xtests
00152 {
00153 namespace c
00154 {
00155 #endif /* !_XTESTS_NO_NAMESPACE */
00156 
00157 /* /////////////////////////////////////////////////////////////////////////
00158  * Features
00159  */
00160 
00161 #ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
00162 
00163 # ifndef XTESTS_CALL
00164 #  ifdef __cplusplus
00165 #   define XTESTS_CALL(x)                   extern "C" x
00166 #  else /* ? __cplusplus */
00167 #   define XTESTS_CALL(x)                   extern x
00168 #  endif /* __cplusplus */
00169 # endif /* !XTESTS_CALL */
00170 
00171 # ifdef STLSOFT_CF_FUNCTION_SYMBOL_SUPPORT
00172 #  define XTESTS_GET_FUNCTION_()            __FUNCTION__
00173 # else /* ? STLSOFT_CF_FUNCTION_SYMBOL_SUPPORT */
00174 #  define XTESTS_GET_FUNCTION_()            stlsoft_static_cast(char const*, 0)
00175 # endif /* STLSOFT_CF_FUNCTION_SYMBOL_SUPPORT */
00176 
00177 # ifndef _XTESTS_NO_NAMESPACE
00178 #  define XTESTS_NS_QUAL(ns, sym)           ns::sym
00179 # else /* ? _XTESTS_NO_NAMESPACE */
00180 #  define XTESTS_NS_QUAL(ns, sym)           sym
00181 # endif /* _XTESTS_NO_NAMESPACE */
00182 
00183 # define XTESTS_NS_C_QUAL(sym)              XTESTS_NS_QUAL(xtests::c, sym)
00184 # define XTESTS_NS_CPP_QUAL(sym)            XTESTS_NS_QUAL(xtests::c::cpp, sym)
00185 
00186 # ifdef STLSOFT_CF_RTTI_SUPPORT
00187 #  define XTESTS_REPORT_EXCEPTION_(x)       XTESTS_NS_C_QUAL(xtests_caseExcepted)(typeid(x).name(), x.what())
00188 # else /* ? STLSOFT_CF_RTTI_SUPPORT */
00189 #  define XTESTS_REPORT_EXCEPTION_(x)       XTESTS_NS_C_QUAL(xtests_caseExcepted)("<rtti not available>", x.what())
00190 # endif /* STLSOFT_CF_RTTI_SUPPORT */
00191 
00192 # if defined(STLSOFT_CF_EXCEPTION_SUPPORT)
00193 
00194 #  define XTESTS_INVOKE_TEST_CASE_FN_(fn, name)                                         \
00195                                                                                         \
00196     do                                                                                  \
00197     {                                                                                   \
00198         try                                                                             \
00199         {                                                                               \
00200             (*fn)();                                                                    \
00201         }                                                                               \
00202         catch(std::bad_alloc& x)                                                        \
00203         {                                                                               \
00204             XTESTS_REPORT_EXCEPTION_(x);                                                \
00205                                                                                         \
00206             throw;                                                                      \
00207         }                                                                               \
00208         catch(std::exception& x)                                                        \
00209         {                                                                               \
00210             XTESTS_REPORT_EXCEPTION_(x);                                                \
00211                                                                                         \
00212             /* XTESTS_CASE_END(name); */                                                      \
00213                                                                                         \
00214             /* throw; */                                                                      \
00215         }                                                                               \
00216     } while(0)
00217 
00218 #  define XTESTS_INVOKE_TEST_CASE_FN_THROWS_(fn, name, type)                            \
00219                                                                                         \
00220     do                                                                                  \
00221     {                                                                                   \
00222         try                                                                             \
00223         {                                                                               \
00224             (*fn)();                                                                    \
00225                                                                                         \
00226             XTESTS_NS_C_QUAL(xtests_caseExceptionExpected)(#type);                      \
00227         }                                                                               \
00228         catch(type& /* x */)                                                            \
00229         {                                                                               \
00230             XTESTS_TEST_PASSED();                                                       \
00231         }                                                                               \
00232         catch(std::bad_alloc& x)                                                        \
00233         {                                                                               \
00234             XTESTS_REPORT_EXCEPTION_(x);                                                \
00235                                                                                         \
00236             throw;                                                                      \
00237         }                                                                               \
00238         catch(std::exception& x)                                                        \
00239         {                                                                               \
00240             XTESTS_REPORT_EXCEPTION_(x);                                                \
00241                                                                                         \
00242             /* XTESTS_CASE_END(name); */                                                      \
00243                                                                                         \
00244             /* throw; */                                                                      \
00245         }                                                                               \
00246     } while(0)
00247 
00248 # else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
00249 
00250 #  define XTESTS_INVOKE_TEST_CASE_FN_(fn, name)  (*fn)()
00251 
00252 # endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
00253 
00254 
00255 
00256 # if defined(STLSOFT_COMPILER_IS_DMC)
00257 #  define XTESTS_INVOKE_c_str_data_a_(x)        stlsoft_ns_qual(c_str_data_a)(x)
00258 #  define XTESTS_INVOKE_c_str_data_w_(x)        stlsoft_ns_qual(c_str_data_w)(x)
00259 #  define XTESTS_INVOKE_c_str_len_a_(x)         stlsoft_ns_qual(c_str_len_a)(x)
00260 #  define XTESTS_INVOKE_c_str_len_w_(x)         stlsoft_ns_qual(c_str_len_w)(x)
00261 #  define XTESTS_INVOKE_c_str_ptr_a_(x)         stlsoft_ns_qual(c_str_ptr_a)(x)
00262 #  define XTESTS_INVOKE_c_str_ptr_w_(x)         stlsoft_ns_qual(c_str_ptr_w)(x)
00263 # elif defined(STLSOFT_COMPILER_IS_GCC)         
00264 #  define XTESTS_INVOKE_c_str_data_a_(x)        c_str_data_a(x)
00265 #  define XTESTS_INVOKE_c_str_data_w_(x)        c_str_data_w(x)
00266 #  define XTESTS_INVOKE_c_str_len_a_(x)         c_str_len_a(x)
00267 #  define XTESTS_INVOKE_c_str_len_w_(x)         c_str_len_w(x)
00268 #  define XTESTS_INVOKE_c_str_ptr_a_(x)         c_str_ptr_a(x)
00269 #  define XTESTS_INVOKE_c_str_ptr_w_(x)         c_str_ptr_w(x)
00270 # else /* ? compiler */                         
00271 #  define XTESTS_INVOKE_c_str_data_a_(x)        c_str_data_a(x)
00272 #  define XTESTS_INVOKE_c_str_data_w_(x)        c_str_data_w(x)
00273 #  define XTESTS_INVOKE_c_str_len_a_(x)         c_str_len_a(x)
00274 #  define XTESTS_INVOKE_c_str_len_w_(x)         c_str_len_w(x)
00275 #  define XTESTS_INVOKE_c_str_ptr_a_(x)         c_str_ptr_a(x)
00276 #  define XTESTS_INVOKE_c_str_ptr_w_(x)         c_str_ptr_w(x)
00277 # endif /* compiler */
00278 
00279 
00280 #endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
00281 
00282 /* /////////////////////////////////////////////////////////////////////////
00283  * Constants & definitions
00284  */
00285 
00293 enum xtests_runner_flags_t
00294 {
00295         xtestsRunnerFlagsNoWindowsDebugString   =   0x0001
00296     ,   xtestsReportOnlyNonEmptyCases           =   0x0002
00297 };
00298 #ifndef __cplusplus
00299 typedef enum xtests_runner_flags_t xtests_runner_flags_t;
00300 #endif /* !__cplusplus */
00301 
00306 #define XTESTS_FP_APPROXIMATE_FACTOR                    (1.000001)
00307 
00308 /* /////////////////////////////////////////////////////////////////////////
00309  * Macros
00310  */
00311 
00346 #define XTESTS_START_RUNNER(name, verbosity)                                            \
00347                                                                                         \
00348     (0 == XTESTS_NS_C_QUAL(xtests_startRunner)((name), (verbosity), NULL, NULL, stdout, 0))
00349 
00350 
00364 #define XTESTS_START_RUNNER_WITH_STREAM(name, verbosity, stm)                           \
00365                                                                                         \
00366     (0 == XTESTS_NS_C_QUAL(xtests_startRunner)((name), (verbosity), NULL, NULL, stm, 0))
00367 
00368 
00384 #define XTESTS_START_RUNNER_WITH_REPORTER(name, verbosity, reporter, reporterParam)     \
00385                                                                                         \
00386     (0 == XTESTS_NS_C_QUAL(xtests_startRunner)((name), (verbosity), (reporter), (reporterParam), stdout, 0))
00387 
00388 
00405 #define XTESTS_START_RUNNER_WITH_REPORTER_AND_STREAM(name, verbosity, reporter, reporterParam, stm) \
00406                                                                                                     \
00407     (0 == XTESTS_NS_C_QUAL(xtests_startRunner)((name), (verbosity), (reporter), (reporterParam), stm, 0))
00408 
00409 
00428 #define XTESTS_START_RUNNER_WITH_REPORTER_AND_STREAM_AND_FLAGS(name, verbosity, reporter, reporterParam, stm, flags) \
00429                                                                                                     \
00430     (0 == XTESTS_NS_C_QUAL(xtests_startRunner)((name), (verbosity), (reporter), (reporterParam), (stm), (flags)))
00431 
00432 
00447 #define XTESTS_START_RUNNER_WITH_FLAGS(name, verbosity, flags)                          \
00448                                                                                         \
00449     (0 == XTESTS_NS_C_QUAL(xtests_startRunner)((name), (verbosity), NULL, NULL, stdout, (flags)))
00450 
00451 
00463 #define XTESTS_PRINT_RESULTS()                                                          \
00464                                                                                         \
00465     XTESTS_NS_C_QUAL(xtests_printRunnerResults)()
00466 
00467 
00474 #define XTESTS_END_RUNNER()                                                             \
00475                                                                                         \
00476     XTESTS_NS_C_QUAL(xtests_endRunner)(NULL)
00477 
00478 
00485 #define XTESTS_ABEND(terminationMessage)                                                \
00486                                                                                         \
00487     XTESTS_NS_C_QUAL(xtests_abend)(terminationMessage)
00488 
00489 
00505 #define XTESTS_END_RUNNER_UPDATE_EXITCODE(retCode)                                      \
00506                                                                                         \
00507     stlsoft_static_cast(void, XTESTS_NS_C_QUAL(xtests_endRunner)(retCode))
00508 
00509 
00510 
00511 
00522 #define XTESTS_CASE_BEGIN(name, desc)                                                   \
00523                                                                                         \
00524     (0 == XTESTS_NS_C_QUAL(xtests_beginTestCase)((name), (desc)))
00525 
00526 
00538 #define XTESTS_CASE_END(name)                                                           \
00539                                                                                         \
00540     stlsoft_static_cast(void, XTESTS_NS_C_QUAL(xtests_endTestCase)((name)))
00541 
00542 
00558 #define XTESTS_RUN_CASE_WITH_NAME_AND_DESC(name, desc, fn)                              \
00559                                                                                         \
00560     do                                                                                  \
00561     {                                                                                   \
00562         if(XTESTS_CASE_BEGIN(name, desc))                                               \
00563         {                                                                               \
00564             XTESTS_INVOKE_TEST_CASE_FN_(fn, name);                                      \
00565                                                                                         \
00566             XTESTS_CASE_END(name);                                                      \
00567         }                                                                               \
00568                                                                                         \
00569     } while(0)
00570 
00571 
00586 #define XTESTS_RUN_CASE_WITH_DESC(fn, desc)                                             \
00587                                                                                         \
00588     XTESTS_RUN_CASE_WITH_NAME_AND_DESC(#fn, desc, fn)
00589                                                                                         \
00603 #define XTESTS_RUN_CASE(fn)                                                             \
00604                                                                                         \
00605     XTESTS_RUN_CASE_WITH_DESC(fn, "")
00606 
00607 
00608 #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
00609 
00627 # define XTESTS_RUN_CASE_THAT_THROWS_WITH_NAME_AND_DESC(name, desc, fn, type)           \
00628                                                                                         \
00629     do                                                                                  \
00630     {                                                                                   \
00631         if(XTESTS_CASE_BEGIN(name, desc))                                               \
00632         {                                                                               \
00633             XTESTS_INVOKE_TEST_CASE_FN_THROWS_(fn, name, type);                         \
00634                                                                                         \
00635             XTESTS_CASE_END(name);                                                      \
00636         }                                                                               \
00637                                                                                         \
00638     } while(0)
00639 
00656 # define XTESTS_RUN_CASE_THAT_THROWS_WITH_DESC(fn, desc, type)                          \
00657                                                                                         \
00658     XTESTS_RUN_CASE_THAT_THROWS_WITH_NAME_AND_DESC(#fn, desc, fn, type)
00659 
00675 # define XTESTS_RUN_CASE_THAT_THROWS(fn, type)                                          \
00676                                                                                         \
00677     XTESTS_RUN_CASE_THAT_THROWS_WITH_NAME_AND_DESC(#fn, "", fn, type)
00678 
00679 #endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
00680 
00681 
00695 #define XTESTS_TEST_FAIL_WITH_QUALIFIER(msg, qualifier)                                 \
00696                                                                                         \
00697     XTESTS_NS_C_QUAL(xtests_writeFailMessage)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), msg, qualifier)
00698 
00710 #define XTESTS_TEST_FAIL(msg)                                                           \
00711                                                                                         \
00712     XTESTS_TEST_FAIL_WITH_QUALIFIER(msg, stlsoft_static_cast(char const*, NULL))
00713 
00723 #define XTESTS_TEST_PASSED()                                                            \
00724                                                                                         \
00725     XTESTS_NS_C_QUAL(xtests_testPassed)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "")
00726 
00740 #define XTESTS_TEST_WITH_MESSAGE(expr, msg)                                             \
00741                                                                                         \
00742     ((expr)                                                                             \
00743         ? XTESTS_NS_C_QUAL(xtests_testPassed)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), msg)   \
00744         : XTESTS_NS_C_QUAL(xtests_testFailed)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), msg))
00745 
00757 #define XTESTS_TEST(expr)                                                               \
00758                                                                                         \
00759     XTESTS_TEST_WITH_MESSAGE(expr, #expr)
00760 
00761 
00762 
00777 #define XTESTS_TEST_ENUM_EQUAL(expected, actual)                    XTESTS_TEST_INTEGER_EQUAL_EXACT(stlsoft_static_cast(int, (expected)), stlsoft_static_cast(int, (actual)))
00778 
00793 #define XTESTS_TEST_ENUM_NOT_EQUAL(expected, actual)                XTESTS_TEST_INTEGER_NOT_EQUAL(stlsoft_static_cast(int, (expected)), stlsoft_static_cast(int, (actual)))
00794 
00795 
00796 #if defined(__cplusplus) && \
00797     !defined(_XTESTS_NO_CPP_API)
00798 
00813 # define XTESTS_TEST_INTEGER_EQUAL_EXACT(expected, actual)                              \
00814                                                                                         \
00815     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual)))
00816 
00831 # define XTESTS_TEST_INTEGER_NOT_EQUAL(expected, actual)                                \
00832                                                                                         \
00833     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual)))
00834 
00847 # define XTESTS_TEST_INTEGER_GREATER(expected, actual)                                  \
00848                                                                                         \
00849     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonGreaterThan)))
00850 
00863 # define XTESTS_TEST_INTEGER_LESS(expected, actual)                                     \
00864                                                                                         \
00865     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonLessThan)))
00866 
00880 # define XTESTS_TEST_INTEGER_GREATER_OR_EQUAL(expected, actual)                         \
00881                                                                                         \
00882     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonGreaterThanOrEqual)))
00883 
00897 # define XTESTS_TEST_INTEGER_LESS_OR_EQUAL(expected, actual)                            \
00898                                                                                         \
00899     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonLessThanOrEqual)))
00900 
00901 
00902 
00915 # define XTESTS_TEST_BOOLEAN_EQUAL(expected, actual)                                    \
00916                                                                                         \
00917     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual)))
00918 
00931 # define XTESTS_TEST_BOOLEAN_NOT_EQUAL(expected, actual)                                \
00932                                                                                         \
00933     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual)))
00934 
00946 # define XTESTS_TEST_BOOLEAN_TRUE(actual)                                               \
00947                                                                                         \
00948     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", true, (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual)))
00949 
00961 # define XTESTS_TEST_BOOLEAN_FALSE(actual)                                               \
00962                                                                                         \
00963     XTESTS_NS_CPP_QUAL(xtests_test_integer(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", false, (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual)))
00964 
00965 
00980 # define XTESTS_TEST_CHARACTER_EQUAL_EXACT(expected, actual)                            \
00981                                                                                         \
00982     XTESTS_NS_CPP_QUAL(xtests_test_character(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual)))
00983 
00998 # define XTESTS_TEST_CHARACTER_NOT_EQUAL(expected, actual)                              \
00999                                                                                         \
01000     XTESTS_NS_CPP_QUAL(xtests_test_character(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual)))
01001 
01014 # define XTESTS_TEST_CHARACTER_GREATER(expected, actual)                                \
01015                                                                                         \
01016     XTESTS_NS_CPP_QUAL(xtests_test_character(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonGreaterThan)))
01017 
01030 # define XTESTS_TEST_CHARACTER_LESS(expected, actual)                                   \
01031                                                                                         \
01032     XTESTS_NS_CPP_QUAL(xtests_test_character(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonLessThan)))
01033 
01047 # define XTESTS_TEST_CHARACTER_GREATER_OR_EQUAL(expected, actual)                       \
01048                                                                                         \
01049     XTESTS_NS_CPP_QUAL(xtests_test_character(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonGreaterThanOrEqual)))
01050 
01064 # define XTESTS_TEST_CHARACTER_LESS_OR_EQUAL(expected, actual)                          \
01065                                                                                         \
01066     XTESTS_NS_CPP_QUAL(xtests_test_character(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonLessThanOrEqual)))
01067 
01068 
01069 
01082 # define XTESTS_TEST_FLOATINGPOINT_EQUAL_EXACT(expected, actual)                        \
01083                                                                                         \
01084     XTESTS_NS_CPP_QUAL(xtests_test_floating_point(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual)))
01085 
01099 # define XTESTS_TEST_FLOATINGPOINT_EQUAL_APPROX(expected, actual)                       \
01100                                                                                         \
01101     XTESTS_NS_CPP_QUAL(xtests_test_floating_point(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxEqual)))
01102 
01103 #else /* ? __cplusplus) && !_XTESTS_NO_CPP_API */
01104 
01105 # define XTESTS_TEST_INTEGER_EQUAL_EXACT(expected, actual)          XTESTS_TEST((expected) == (actual))
01106 # define XTESTS_TEST_INTEGER_NOT_EQUAL(expected, actual)            XTESTS_TEST((expected) != (actual))
01107 # define XTESTS_TEST_INTEGER_GREATER(expected, actual)              XTESTS_TEST((expected) < (actual))
01108 # define XTESTS_TEST_INTEGER_LESS(expected, actual)                 XTESTS_TEST((expected) > (actual))
01109 # define XTESTS_TEST_INTEGER_GREATER_OR_EQUAL(expected, actual)     XTESTS_TEST((expected) <= (actual))
01110 # define XTESTS_TEST_INTEGER_LESS_OR_EQUAL(expected, actual)        XTESTS_TEST((expected) >= (actual))
01111 
01112 # define XTESTS_TEST_BOOLEAN_EQUAL(expected, actual)                XTESTS_TEST((expected) == (actual))
01113 # define XTESTS_TEST_BOOLEAN_NOT_EQUAL(expected, actual)            XTESTS_TEST((expected) != (actual))
01114 # define XTESTS_TEST_BOOLEAN_TRUE(actual)                           XTESTS_TEST((actual))
01115 # define XTESTS_TEST_BOOLEAN_FALSE(actual)                          XTESTS_TEST(!(actual))
01116 
01117 # define XTESTS_TEST_CHARACTER_EQUAL_EXACT(expected, actual)        XTESTS_TEST((expected) == (actual))
01118 # define XTESTS_TEST_CHARACTER_NOT_EQUAL(expected, actual)          XTESTS_TEST((expected) != (actual))
01119 # define XTESTS_TEST_CHARACTER_GREATER(expected, actual)            XTESTS_TEST((expected) < (actual))
01120 # define XTESTS_TEST_CHARACTER_LESS(expected, actual)               XTESTS_TEST((expected) > (actual))
01121 # define XTESTS_TEST_CHARACTER_GREATER_OR_EQUAL(expected, actual)   XTESTS_TEST((expected) <= (actual))
01122 # define XTESTS_TEST_CHARACTER_LESS_OR_EQUAL(expected, actual)      XTESTS_TEST((expected) >= (actual))
01123 
01124 # define XTESTS_TEST_FLOATINGPOINT_EQUAL_APPROX(expected, actual)   XTESTS_TEST(xtests_floatingPointClose((expected), (actual)))
01125 
01126 #endif /* __cplusplus) && !_XTESTS_NO_CPP_API */
01127 
01128 
01141 #define XTESTS_TEST_INTEGER_EQUAL(expected, actual)                 XTESTS_TEST_INTEGER_EQUAL_EXACT(expected, actual)
01142 
01155 #define XTESTS_TEST_FLOATINGPOINT_EQUAL(expected, actual)           XTESTS_TEST_FLOATINGPOINT_EQUAL_APPROX(expected, actual)
01156 
01169 #define XTESTS_TEST_CHARACTER_EQUAL(expected, actual)               XTESTS_TEST_CHARACTER_EQUAL_EXACT(expected, actual)
01170 
01171 
01172 
01185 #define XTESTS_TEST_MULTIBYTE_STRING_EQUAL(expected, actual)                            \
01186                                                                                         \
01187     XTESTS_NS_C_QUAL(xtests_testMultibyteStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual))
01188 
01202 #define XTESTS_TEST_MULTIBYTE_STRING_EQUAL_APPROX(expected, actual)                     \
01203                                                                                         \
01204     XTESTS_NS_C_QUAL(xtests_testMultibyteStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxEqual))
01205 
01218 #define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL(expected, actual)                        \
01219                                                                                         \
01220     XTESTS_NS_C_QUAL(xtests_testMultibyteStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual))
01221 
01235 #define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL_APPROX(expected, actual)                        \
01236                                                                                         \
01237     XTESTS_NS_C_QUAL(xtests_testMultibyteStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxNotEqual))
01238 
01252 #define XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N(expected, actual, n)                       \
01253                                                                                         \
01254     XTESTS_NS_C_QUAL(xtests_testMultibyteStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonEqual))
01255 
01270 #define XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N_APPROX(expected, actual, n)                \
01271                                                                                         \
01272     XTESTS_NS_C_QUAL(xtests_testMultibyteStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonApproxEqual))
01273 
01287 #define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL_N(expected, actual, n)                   \
01288                                                                                         \
01289     XTESTS_NS_C_QUAL(xtests_testMultibyteStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonNotEqual))
01290 
01305 #define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL_N_APPROX(expected, actual, n)            \
01306                                                                                         \
01307     XTESTS_NS_C_QUAL(xtests_testMultibyteStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonApproxNotEqual))
01308 
01309 
01322 #define XTESTS_TEST_WIDE_STRING_EQUAL(expected, actual)                                 \
01323                                                                                         \
01324     XTESTS_NS_C_QUAL(xtests_testWideStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual))
01325 
01338 #define XTESTS_TEST_WIDE_STRING_EQUAL_APPROX(expected, actual)                          \
01339                                                                                         \
01340     XTESTS_NS_C_QUAL(xtests_testWideStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxEqual))
01341 
01354 #define XTESTS_TEST_WIDE_STRING_NOT_EQUAL(expected, actual)                             \
01355                                                                                         \
01356     XTESTS_NS_C_QUAL(xtests_testWideStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual))
01357 
01371 #define XTESTS_TEST_WIDE_STRING_NOT_EQUAL_APPROX(expected, actual)                        \
01372                                                                                         \
01373     XTESTS_NS_C_QUAL(xtests_testWideStrings)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxNotEqual))
01374 
01388 #define XTESTS_TEST_WIDE_STRING_EQUAL_N(expected, actual, n)                            \
01389                                                                                         \
01390     XTESTS_NS_C_QUAL(xtests_testWideStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonEqual))
01391 
01406 #define XTESTS_TEST_WIDE_STRING_EQUAL_N_APPROX(expected, actual, n)                     \
01407                                                                                         \
01408     XTESTS_NS_C_QUAL(xtests_testWideStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonApproxEqual))
01409 
01423 #define XTESTS_TEST_WIDE_STRING_NOT_EQUAL_N(expected, actual, n)                        \
01424                                                                                         \
01425     XTESTS_NS_C_QUAL(xtests_testWideStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonNotEqual))
01426 
01440 #define XTESTS_TEST_WIDE_STRING_NOT_EQUAL_N_APPROX(expected, actual, n)                 \
01441                                                                                         \
01442     XTESTS_NS_C_QUAL(xtests_testWideStringsN)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), n, XTESTS_NS_C_QUAL(xtestsComparisonApproxNotEqual))
01443 
01444 
01445 
01458 #define XTESTS_TEST_MULTIBYTE_STRING_CONTAIN(expected, actual)                          \
01459                                                                                         \
01460     XTESTS_NS_C_QUAL(xtests_testMultibyteStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual))
01461 
01475 #define XTESTS_TEST_MULTIBYTE_STRING_CONTAIN_APPROX(expected, actual)                   \
01476                                                                                         \
01477     XTESTS_NS_C_QUAL(xtests_testMultibyteStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxEqual))
01478 
01491 #define XTESTS_TEST_MULTIBYTE_STRING_NOT_CONTAIN(expected, actual)                      \
01492                                                                                         \
01493     XTESTS_NS_C_QUAL(xtests_testMultibyteStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual))
01494 
01508 #define XTESTS_TEST_MULTIBYTE_STRING_NOT_CONTAIN_APPROX(expected, actual)               \
01509                                                                                         \
01510     XTESTS_NS_C_QUAL(xtests_testMultibyteStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxNotEqual))
01511 
01512 
01513 
01526 #define XTESTS_TEST_WIDE_STRING_CONTAIN(expected, actual)                               \
01527                                                                                         \
01528     XTESTS_NS_C_QUAL(xtests_testWideStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual))
01529 
01543 #define XTESTS_TEST_WIDE_STRING_CONTAIN_APPROX(expected, actual)                        \
01544                                                                                         \
01545     XTESTS_NS_C_QUAL(xtests_testWideStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxEqual))
01546 
01559 #define XTESTS_TEST_WIDE_STRING_NOT_CONTAIN(expected, actual)                           \
01560                                                                                         \
01561     XTESTS_NS_C_QUAL(xtests_testWideStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual))
01562 
01575 #define XTESTS_TEST_WIDE_STRING_NOT_CONTAIN_APPROX(expected, actual)                    \
01576                                                                                         \
01577     XTESTS_NS_C_QUAL(xtests_testWideStringContains)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonApproxNotEqual))
01578 
01579 
01580 
01593 #define XTESTS_TEST_POINTER_EQUAL(expected, actual)                                     \
01594                                                                                         \
01595     XTESTS_NS_C_QUAL(xtests_testPointers)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonEqual))
01596 
01611 # define XTESTS_TEST_POINTER_NOT_EQUAL(expected, actual)                                \
01612                                                                                         \
01613     XTESTS_NS_C_QUAL(xtests_testPointers)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonNotEqual))
01614 
01627 # define XTESTS_TEST_POINTER_GREATER(expected, actual)                                  \
01628                                                                                         \
01629     XTESTS_NS_C_QUAL(xtests_testPointers)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonGreaterThan))
01630 
01643 # define XTESTS_TEST_POINTER_LESS(expected, actual)                                     \
01644                                                                                         \
01645     XTESTS_NS_C_QUAL(xtests_testPointers)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonLessThan))
01646 
01660 # define XTESTS_TEST_POINTER_GREATER_OR_EQUAL(expected, actual)                         \
01661                                                                                         \
01662     XTESTS_NS_C_QUAL(xtests_testPointers)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonGreaterThanOrEqual))
01663 
01677 # define XTESTS_TEST_POINTER_LESS_OR_EQUAL(expected, actual)                            \
01678                                                                                         \
01679     XTESTS_NS_C_QUAL(xtests_testPointers)(__FILE__, __LINE__, XTESTS_GET_FUNCTION_(), "", (expected), (actual), XTESTS_NS_C_QUAL(xtestsComparisonLessThanOrEqual))
01680 
01681 
01682 /* /////////////////////////////////////////////////////////////////////////
01683  * Helper functions
01684  */
01685 
01686 #ifdef __cplusplus
01687 # if !defined(_XTESTS_NO_CPP_API)
01688 #  ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
01689 
01690 /* c_str_len_n_X(s, n)
01691  *
01692  * prevents len-limited strlen() from overstepping
01693  */
01694 
01695 inline size_t c_str_len_n_a(char const* s, size_t n)
01696 {
01697     size_t len = 0;
01698 
01699     for(; '\0' != *s && len != n; ++s, ++len)
01700     {}
01701 
01702     return len;
01703 }
01704 
01705 inline size_t c_str_len_n_w(wchar_t const* s, size_t n)
01706 {
01707     size_t len = 0;
01708 
01709     for(; '\0' != *s && len != n; ++s, ++len)
01710     {}
01711 
01712     return len;
01713 }
01714 
01715 template <typename S>
01716 inline size_t c_str_len_n_a(S const& s, size_t n)
01717 {
01718     stlsoft_ns_using(c_str_len_a);
01719 
01720     size_t len = XTESTS_INVOKE_c_str_len_a_(s);
01721 
01722     return (len < n) ? len : n;
01723 }
01724 
01725 template <typename S>
01726 inline size_t c_str_len_n_w(S const& s, size_t n)
01727 {
01728     stlsoft_ns_using(c_str_len_w);
01729 
01730     size_t len = XTESTS_INVOKE_c_str_len_w_(s);
01731 
01732     return (len < n) ? len : n;
01733 }
01734 
01735 #  endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
01736 # endif /* !_XTESTS_NO_CPP_API */
01737 #endif /* __cplusplus */
01738 
01739 /* /////////////////////////////////////////////////////////////////////////
01740  * API functions
01741  */
01742 
01750 enum xtests_verbosity_t
01751 {
01752         xtestsVerbositySilent           =   0   
01753     ,   xtestsVerbositySummaryOnError   =   1   
01754     ,   xtestsVerbosityVerboseOnError   =   2   
01755     ,   xtestsVerbositySummaryOnSuccess =   3   
01756     ,   xtestsVerbosityVerboseOnSuccess =   4   
01758 };
01759 #ifndef __cplusplus
01760 typedef enum xtests_verbosity_t xtests_verbosity_t;
01761 #endif /* !__cplusplus */
01762 
01763 
01764 #ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
01765 
01766 enum xtests_comparison_t
01767 {
01768     /* NOTE: NEVER CHANGE THE ORDER OF THESE ENUMERATORS !!!!!!!!!!! */
01769 
01770         xtestsComparisonEqual               =   0
01771     ,   xtestsComparisonNotEqual
01772     ,   xtestsComparisonGreaterThan
01773     ,   xtestsComparisonLessThan
01774     ,   xtestsComparisonGreaterThanOrEqual
01775     ,   xtestsComparisonLessThanOrEqual
01776     ,   xtestsComparisonApproxEqual
01777     ,   xtestsComparisonApproxNotEqual
01778     ,   xtestsComparison_max_enumerator
01779 
01780     /* NOTE: NEVER CHANGE THE ORDER OF THESE ENUMERATORS !!!!!!!!!!! */
01781 
01782 };
01783 # ifndef __cplusplus
01784 typedef enum xtests_comparison_t xtests_comparison_t;
01785 # endif /* !__cplusplus */
01786 
01787 
01788 # ifdef __cplusplus
01789 
01790 enum xtests_variable_type_t
01791 {
01792         xtestsVariableNone                  =   0
01793     ,   xtestsVariableBoolean               =   1
01794     ,   xtestsVariableOpaquePointer         =   3
01795     ,   xtestsVariableMultibyteCharacter    =   5
01796     ,   xtestsVariableWideCharacter         =   6
01797     ,   xtestsVariableMultibyteString       =   7
01798     ,   xtestsVariableWideString            =   8
01799     ,   xtestsVariableSignedChar            =   11
01800     ,   xtestsVariableUnsignedChar          =   12
01801     ,   xtestsVariableShort                 =   13
01802     ,   xtestsVariableUnsignedShort         =   14
01803     ,   xtestsVariableInt                   =   15
01804     ,   xtestsVariableUnsignedInt           =   16
01805     ,   xtestsVariableLong                  =   17
01806     ,   xtestsVariableUnsignedLong          =   18
01807 #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
01808     ,   xtestsVariableLongLong              =   19
01809     ,   xtestsVariableUnsignedLongLong      =   20
01810 #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
01811     ,   xtestsVariableDouble                =   31
01812 };
01813 #ifndef __cplusplus
01814 typedef enum xtests_variable_type_t xtests_variable_type_t;
01815 #endif /* !__cplusplus */
01816 
01817 enum xtests_test_type_t
01818 {
01819         xtestsTestFullComparison            =   0
01820     ,   xtestsTestPartialComparison         =   1
01821     ,   xtestsTestContainment               =   2
01822 };
01823 #ifndef __cplusplus
01824 typedef enum xtests_test_type_t xtests_test_type_t;
01825 #endif /* !__cplusplus */
01826 
01827 union xtests_variable_value_t
01828 {
01829     int                             booleanValue;
01830     int                             intValue;
01831     unsigned int                    uintValue;
01832     long                            longValue;
01833     unsigned long                   ulongValue;
01834 #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
01835     stlsoft_ns_qual(ss_sint64_t)    longlongValue;
01836     stlsoft_ns_qual(ss_uint64_t)    ulonglongValue;
01837 #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
01838     char                            multibyteCharacterValue;
01839     wchar_t                         wideCharacterValue;
01840     char const*                     multibyteStringValue;
01841     wchar_t const*                  wideStringValue;
01842     double                          doubleValue;
01843     void const volatile*            opaquePointerValue;
01844 
01845     explicit xtests_variable_value_t(bool b);
01846     explicit xtests_variable_value_t(char ch);
01847     explicit xtests_variable_value_t(wchar_t ch, xtests_variable_type_t type /* = xtestsVariableMultibyteCharacter */);
01848     explicit xtests_variable_value_t(signed   int i);
01849     explicit xtests_variable_value_t(unsigned int i);
01850     explicit xtests_variable_value_t(signed   long i);
01851     explicit xtests_variable_value_t(unsigned long i);
01852 #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
01853     explicit xtests_variable_value_t(stlsoft_ns_qual(ss_sint64_t) const& i);
01854     explicit xtests_variable_value_t(stlsoft_ns_qual(ss_uint64_t) const& i);
01855 #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
01856     explicit xtests_variable_value_t(char const* s);
01857     explicit xtests_variable_value_t(wchar_t const* s);
01858     explicit xtests_variable_value_t(char const* s, size_t n);
01859     explicit xtests_variable_value_t(wchar_t const* s, size_t n);
01860     explicit xtests_variable_value_t(double const& d);
01861     explicit xtests_variable_value_t(void const volatile* pv);
01862 };
01863 #ifndef __cplusplus
01864 typedef union xtests_variable_value_t xtests_variable_value_t;
01865 #endif /* !__cplusplus */
01866 
01867 struct xtests_variable_t
01868 {
01869     xtests_variable_type_t  variableType;
01870     xtests_test_type_t      testType;
01871     xtests_variable_value_t value;
01872     size_t                  valueLen;
01873 
01874 public:
01875     explicit xtests_variable_t(char ch);
01876     explicit xtests_variable_t(wchar_t ch, xtests_variable_type_t type /* = xtestsVariableMultibyteCharacter */);
01877     explicit xtests_variable_t(bool b);
01878     explicit xtests_variable_t(int b, xtests_variable_type_t type /* = xtestsVariableBoolean */);
01879     explicit xtests_variable_t(signed   char i);
01880     explicit xtests_variable_t(unsigned char i);
01881     explicit xtests_variable_t(signed   short i);
01882     explicit xtests_variable_t(unsigned short i);
01883     explicit xtests_variable_t(signed   int i);
01884     explicit xtests_variable_t(unsigned int i);
01885     explicit xtests_variable_t(signed   long i);
01886     explicit xtests_variable_t(unsigned long i);
01887 #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
01888     explicit xtests_variable_t(stlsoft_ns_qual(ss_sint64_t) const& i);
01889     explicit xtests_variable_t(stlsoft_ns_qual(ss_uint64_t) const& i);
01890 #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
01891     explicit xtests_variable_t(char const* s, size_t n, xtests_test_type_t testType = xtestsTestFullComparison);
01892     explicit xtests_variable_t(wchar_t const* s, size_t n, xtests_test_type_t testType = xtestsTestFullComparison);
01893     explicit xtests_variable_t(char const* s, xtests_test_type_t testType = xtestsTestFullComparison);
01894     explicit xtests_variable_t(wchar_t const* s, xtests_test_type_t testType = xtestsTestFullComparison);
01895     explicit xtests_variable_t(double const& d);
01896     explicit xtests_variable_t(void const volatile* pv);
01897 };
01898 #ifndef __cplusplus
01899 typedef union xtests_variable_t xtests_variable_t;
01900 #endif /* !__cplusplus */
01901 
01905 struct xTests_runner_results_t
01906 {
01907     typedef stlsoft_ns_qual(uint32_t)   uint32_t;
01908 
01909     char const*     name;
01910     uint32_t        numCases;
01911     uint32_t        numTests;
01912     uint32_t        numFailedCases;
01913     uint32_t        numFailedTests;
01914     uint32_t        numMissingExpectedExceptions;
01915     uint32_t        numUnexpectedExceptions;
01916 };
01917 
01920 struct xTests_Reporter_t
01921 {
01922 protected:
01923 #  if defined(STLSOFT_COMPILER_IS_GCC)
01924     virtual ~xTests_Reporter_t()
01925     {}
01926 #  else /* ? compiler */
01927     ~xTests_Reporter_t()
01928     {}
01929 private:
01930     virtual void dummy_dtor()
01931     {}
01932 #  endif /* compiler */
01933 
01934 public: /* Overrides */
01935     virtual void onStartRunner(void* reporterParam, char const* name, int verbosity) = 0;
01936 
01937       virtual void onBeginTestCase(void* reporterParam, char const* name, char const* desc, int verbosity) = 0;
01938 
01939         virtual void onTestPassed(void* reporterParam, char const* file, int line, char const* function, char const* expr, xtests_comparison_t comparison, int verbosity) = 0;
01940 
01941         virtual void onTestFailed(void* reporterParam, char const* file, int line, char const* function, char const* expr, xtests_variable_t const* expectedValue, xtests_variable_t const* actualValue, int length, xtests_comparison_t comparison, int verbosity) = 0;
01942 
01943         virtual void onWriteFailMessage(void* reporterParam, char const* file, int line, char const* function, char const* message, char const* qualifyingInformation, int verbosity) = 0;
01944 
01945         virtual void onCaseExcepted(void* reporterParam, char const* caseName, char const* exceptionType, char const* exceptionMessage, int verbosity) = 0;
01946 
01947         virtual void onCaseExceptionExpected(void* reporterParam, char const* caseName, char const* exceptionType, int verbosity) = 0;
01948 
01949       virtual void onEndTestCase(void* reporterParam, char const* name, xTests_runner_results_t const* results, int verbosity) = 0;
01950 
01951       virtual void onPrintRunnerResults(void* reporterParam, xTests_runner_results_t const* results, int verbosity) = 0;
01952 
01953       virtual void onAbend(void* reporterParam, char const* message, int verbosity) = 0;
01954 
01955       virtual void onDefect(void* reporterParam, char const* message, char const* qualifier, int verbosity) = 0;
01956 
01957     virtual void onEndRunner(void* reporterParam, char const* name, int verbosity) = 0;
01958 };
01959 # else /* ? __cplusplus */
01960 struct xTests_Reporter_t;
01961 typedef struct xTests_Reporter_t xTests_Reporter_t;
01962 # endif /* __cplusplus */
01963 
01964 
01965 #endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
01966 
01967 
01968 #ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
01969 
01970 XTESTS_CALL(int) xtests_startRunner(
01971     char const*         name
01972 ,   int                 verbosity
01973 ,   xTests_Reporter_t*  reporter        /* = NULL */
01974 ,   void*               reporterParam   /* = NULL */
01975 ,   FILE*               stm             /* = stdout */
01976 ,   int                 flags           /* = 0 */
01977 );
01978 
01979 XTESTS_CALL(int) xtests_endRunner(int *retCode);
01980 
01981 XTESTS_CALL(void) xtests_printRunnerResults(void);
01982 
01983 XTESTS_CALL(void) xtests_abend(char const* message);
01984 
01985 
01986 XTESTS_CALL(int) xtests_beginTestCase(
01987     char const* name
01988 ,   char const* desc
01989 );
01990 
01991 XTESTS_CALL(int) xtests_endTestCase(char const* name);
01992 
01993 
01994 XTESTS_CALL(int) xtests_testPassed(
01995     char const* file
01996 ,   int         line
01997 ,   char const* function
01998 ,   char const* expr
01999 );
02000 
02001 XTESTS_CALL(int) xtests_testFailed(
02002     char const* file
02003 ,   int         line
02004 ,   char const* function
02005 ,   char const* expr
02006 );
02007 
02008 XTESTS_CALL(int) xtests_testFailed_int(
02009     char const*         file
02010 ,   int                 line
02011 ,   char const*         function
02012 ,   char const*         expr
02013 ,   int                 expected
02014 ,   int                 actual
02015 ,   xtests_comparison_t comp
02016 );
02017 
02018 XTESTS_CALL(int) xtests_testFailed_long(
02019     char const*         file
02020 ,   int                 line
02021 ,   char const*         function
02022 ,   char const*         expr
02023 ,   long                expected
02024 ,   long                actual
02025 ,   xtests_comparison_t comp
02026 );
02027 XTESTS_CALL(int) xtests_testFailed_ulong(
02028     char const*         file
02029 ,   int                 line
02030 ,   char const*         function
02031 ,   char const*         expr
02032 ,   unsigned long       expected
02033 ,   unsigned long       actual
02034 ,   xtests_comparison_t comp
02035 );
02036 # ifdef STLSOFT_CF_64BIT_INT_SUPPORT
02037 XTESTS_CALL(int) xtests_testFailed_longlong(
02038     char const*                     file
02039 ,   int                             line
02040 ,   char const*                     function
02041 ,   char const*                     expr
02042 ,   stlsoft_ns_qual(ss_sint64_t)    expected
02043 ,   stlsoft_ns_qual(ss_sint64_t)    actual
02044 ,   xtests_comparison_t             comp
02045 );
02046 XTESTS_CALL(int) xtests_testFailed_ulonglong(
02047     char const*                     file
02048 ,   int                             line
02049 ,   char const*                     function
02050 ,   char const*                     expr
02051 ,   stlsoft_ns_qual(ss_uint64_t)    expected
02052 ,   stlsoft_ns_qual(ss_uint64_t)    actual
02053 ,   xtests_comparison_t             comp
02054 );
02055 # endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
02056 
02057 XTESTS_CALL(int) xtests_testFailed_boolean(
02058     char const*         file
02059 ,   int                 line
02060 ,   char const*         function
02061 ,   char const*         expr
02062 ,   int                 expected
02063 ,   int                 actual
02064 ,   xtests_comparison_t comp
02065 );
02066 
02067 XTESTS_CALL(int) xtests_testFailed_double(
02068     char const*         file
02069 ,   int                 line
02070 ,   char const*         function
02071 ,   char const*         expr
02072 ,   double              expected
02073 ,   double              actual
02074 ,   xtests_comparison_t comp
02075 );
02076 
02077 XTESTS_CALL(int) xtests_testMultibyteStrings(
02078     char const*         file
02079 ,   int                 line
02080 ,   char const*         function
02081 ,   char const*         expr
02082 ,   char const*         expected
02083 ,   char const*         actual
02084 ,   xtests_comparison_t comp
02085 );
02086 
02087 XTESTS_CALL(int) xtests_testMultibyteStringsN(
02088     char const*         file
02089 ,   int                 line
02090 ,   char const*         function
02091 ,   char const*         expr
02092 ,   char const*         expected
02093 ,   char const*         actual
02094 ,   int                 n /* exact if +ve; limit if -ve */
02095 ,   xtests_comparison_t comp
02096 );
02097 
02098 XTESTS_CALL(int) xtests_testMultibyteStringsN_(
02099     char const*         file
02100 ,   int                 line
02101 ,   char const*         function
02102 ,   char const*         expr
02103 ,   char const*         expected
02104 ,   char const*         actual
02105 ,   int                 n /* exact if +ve; limit if -ve */
02106 ,   size_t              cchExpected
02107 ,   size_t              cchActual
02108 ,   xtests_comparison_t comp
02109 );
02110 
02111 #if defined(__cplusplus) && \
02112     !defined(_XTESTS_NO_CPP_API)
02113 template<   typename S0
02114         ,   typename S1
02115         >
02116 inline int xtests_testMultibyteStrings(
02117     char const*         file
02118 ,   int                 line
02119 ,   char const*         function
02120 ,   char const*         expr
02121 ,   S0 const&           expected
02122 ,   S1 const&           actual
02123 ,   xtests_comparison_t comp
02124 )
02125 {
02126     stlsoft_ns_using(c_str_ptr_a);
02127 
02128     return xtests_testMultibyteStrings(file, line, function, expr, XTESTS_INVOKE_c_str_ptr_a_(XTESTS_INVOKE_c_str_ptr_a_(expected)), XTESTS_INVOKE_c_str_ptr_a_(XTESTS_INVOKE_c_str_ptr_a_(actual)), comp);
02129 }
02130 
02131 template<   typename S0
02132         ,   typename S1
02133         >
02134 inline int xtests_testMultibyteStringsN(
02135     char const*         file
02136 ,   int                 line
02137 ,   char const*         function
02138 ,   char const*         expr
02139 ,   S0 const&           expected
02140 ,   S1 const&           actual
02141 ,   int                 n /* exact if +ve; limit if -ve */
02142 ,   xtests_comparison_t comp
02143 )
02144 {
02145     stlsoft_ns_using(c_str_data_a);
02146 
02147     return xtests_testMultibyteStringsN_(
02148         file
02149     ,   line
02150     ,   function
02151     ,   expr
02152     ,   XTESTS_INVOKE_c_str_data_a_(XTESTS_INVOKE_c_str_data_a_(expected))
02153     ,   XTESTS_INVOKE_c_str_data_a_(XTESTS_INVOKE_c_str_data_a_(actual))
02154     ,   n
02155     ,   c_str_len_n_a(expected, stlsoft_static_cast(size_t, (n < 0) ? -n : n))
02156     ,   c_str_len_n_a(actual, stlsoft_static_cast(size_t, (n < 0) ? -n : n))
02157     ,   comp
02158     );
02159 }
02160 #endif /* C++ && !_XTESTS_NO_CPP_API */
02161 
02162 XTESTS_CALL(int) xtests_testWideStrings(
02163     char const*         file
02164 ,   int                 line
02165 ,   char const*         function
02166 ,   char const*         expr
02167 ,   wchar_t const*      expected
02168 ,   wchar_t const*      actual
02169 ,   xtests_comparison_t comp
02170 );
02171 
02172 XTESTS_CALL(int) xtests_testWideStringsN_(
02173     char const*         file
02174 ,   int                 line
02175 ,   char const*         function
02176 ,   char const*         expr
02177 ,   wchar_t const*      expected
02178 ,   wchar_t const*      actual
02179 ,   int                 n /* exact if +ve; limit if -ve */
02180 ,   size_t              cchExpected
02181 ,   size_t              cchActual
02182 ,   xtests_comparison_t comp
02183 );
02184 
02185 XTESTS_CALL(int) xtests_testWideStringsN(
02186     char const*         file
02187 ,   int                 line
02188 ,   char const*         function
02189 ,   char const*         expr
02190 ,   wchar_t const*      expected
02191 ,   wchar_t const*      actual
02192 ,   int                 n /* exact if +ve; limit if -ve */
02193 ,   xtests_comparison_t comp
02194 );
02195 
02196 #if defined(__cplusplus) && \
02197     !defined(_XTESTS_NO_CPP_API)
02198 template<   typename S0
02199         ,   typename S1
02200         >
02201 inline int xtests_testWideStrings(
02202     char const*         file
02203 ,   int                 line
02204 ,   char const*         function
02205 ,   char const*         expr
02206 ,   S0 const&           expected
02207 ,   S1 const&           actual
02208 ,   xtests_comparison_t comp
02209 )
02210 {
02211     stlsoft_ns_using(c_str_ptr_w);
02212 
02213     return xtests_testWideStrings(file, line, function, expr, XTESTS_INVOKE_c_str_ptr_w_(XTESTS_INVOKE_c_str_ptr_w_(expected)), XTESTS_INVOKE_c_str_ptr_w_(XTESTS_INVOKE_c_str_ptr_w_(actual)), comp);
02214 }
02215 
02216 template<   typename S0
02217         ,   typename S1
02218         >
02219 inline int xtests_testWideStringsN(
02220     char const*         file
02221 ,   int                 line
02222 ,   char const*         function
02223 ,   char const*         expr
02224 ,   S0 const&           expected
02225 ,   S1 const&           actual
02226 ,   int                 n /* exact if +ve; limit if -ve */
02227 ,   xtests_comparison_t comp
02228 )
02229 {
02230     stlsoft_ns_using(c_str_data_w);
02231 
02232     return xtests_testWideStringsN_(
02233         file
02234     ,   line
02235     ,   function
02236     ,   expr
02237     ,   XTESTS_INVOKE_c_str_data_w_(XTESTS_INVOKE_c_str_data_w_(expected))
02238     ,   XTESTS_INVOKE_c_str_data_w_(XTESTS_INVOKE_c_str_data_w_(actual))
02239     ,   n
02240     ,   c_str_len_n_w(expected, stlsoft_static_cast(size_t, (n < 0) ? -n : n))
02241     ,   c_str_len_n_w(actual, stlsoft_static_cast(size_t, (n < 0) ? -n : n))
02242     ,   comp
02243     );
02244 }
02245 #endif /* C++ && !_XTESTS_NO_CPP_API */
02246 
02247 
02248 
02249 
02250 XTESTS_CALL(int) xtests_testMultibyteStringContains(
02251     char const*         file
02252 ,   int                 line
02253 ,   char const*         function
02254 ,   char const*         expr
02255 ,   char const*         expected
02256 ,   char const*         actual
02257 ,   xtests_comparison_t comp
02258 );
02259 
02260 #if defined(__cplusplus) && \
02261     !defined(_XTESTS_NO_CPP_API)
02262 template<   typename S0
02263         ,   typename S1
02264         >
02265 inline int xtests_testMultibyteStringContains(
02266     char const*         file
02267 ,   int                 line
02268 ,   char const*         function
02269 ,   char const*         expr
02270 ,   S0 const&           expected
02271 ,   S1 const&           actual
02272 ,   xtests_comparison_t comp
02273 )
02274 {
02275     stlsoft_ns_using(c_str_ptr_a);
02276 
02277     return xtests_testMultibyteStringContains(file, line, function, expr, XTESTS_INVOKE_c_str_ptr_a_(XTESTS_INVOKE_c_str_ptr_a_(expected)), XTESTS_INVOKE_c_str_ptr_a_(XTESTS_INVOKE_c_str_ptr_a_(actual)), comp);
02278 }
02279 #endif /* C++ && !_XTESTS_NO_CPP_API */
02280 
02281 XTESTS_CALL(int) xtests_testWideStringContains(
02282     char const*         file
02283 ,   int                 line
02284 ,   char const*         function
02285 ,   char const*         expr
02286 ,   wchar_t const*      expected
02287 ,   wchar_t const*      actual
02288 ,   xtests_comparison_t comp
02289 );
02290 
02291 #if defined(__cplusplus) && \
02292     !defined(_XTESTS_NO_CPP_API)
02293 template<   typename S0
02294         ,   typename S1
02295         >
02296 inline int xtests_testWideStringContains(
02297     char const*         file
02298 ,   int                 line
02299 ,   char const*         function
02300 ,   char const*         expr
02301 ,   S0 const&           expected
02302 ,   S1 const&           actual
02303 ,   xtests_comparison_t comp
02304 )
02305 {
02306     stlsoft_ns_using(c_str_ptr_w);
02307 
02308     return xtests_testWideStringContains(file, line, function, expr, XTESTS_INVOKE_c_str_ptr_w_(XTESTS_INVOKE_c_str_ptr_w_(expected)), XTESTS_INVOKE_c_str_ptr_w_(XTESTS_INVOKE_c_str_ptr_w_(actual)), comp);
02309 }
02310 #endif /* C++ && !_XTESTS_NO_CPP_API */
02311 
02312 
02313 
02314 XTESTS_CALL(int) xtests_testPointers(
02315     char const*             file
02316 ,   int                     line
02317 ,   char const*             function
02318 ,   char const*             expr
02319 ,   void volatile const*    expected
02320 ,   void volatile const*    actual
02321 ,   xtests_comparison_t     comp
02322 );
02323 
02324 XTESTS_CALL(int) xtests_testCharactersA(
02325     char const*             file
02326 ,   int                     line
02327 ,   char const*             function
02328 ,   char const*             expr
02329 ,   char                    expected
02330 ,   char                    actual
02331 ,   xtests_comparison_t     comp
02332 );
02333 XTESTS_CALL(int) xtests_testCharactersW(
02334     char const*             file
02335 ,   int                     line
02336 ,   char const*             function
02337 ,   char const*             expr
02338 ,   wchar_t                 expected
02339 ,   wchar_t                 actual
02340 ,   xtests_comparison_t     comp
02341 );
02342 
02343 XTESTS_CALL(int) xtests_writeFailMessage(
02344     char const* file
02345 ,   int         line
02346 ,   char const* function
02347 ,   char const* message
02348 ,   char const* qualifyingInformation
02349 );
02350 
02351 #if defined(__cplusplus) && \
02352     !defined(_XTESTS_NO_CPP_API)
02353 template<   typename S0
02354         ,   typename S1
02355         >
02356 inline int xtests_writeFailMessage(
02357     char const* file
02358 ,   int         line
02359 ,   char const* function
02360 ,   S0 const&   message
02361 ,   S1 const&   qualifyingInformation
02362 )
02363 {
02364     stlsoft_ns_using(c_str_ptr_a);
02365 
02366     return xtests_writeFailMessage(
02367         file
02368     ,   line
02369     ,   function
02370     ,   XTESTS_INVOKE_c_str_ptr_a_(XTESTS_INVOKE_c_str_ptr_a_(message))
02371     ,   XTESTS_INVOKE_c_str_ptr_a_(XTESTS_INVOKE_c_str_ptr_a_(qualifyingInformation)));
02372 }
02373 #endif /* C++ && !_XTESTS_NO_CPP_API */
02374 
02375 XTESTS_CALL(void) xtests_caseExcepted(char const* exceptionType, char const* exceptionMessage);
02376 
02377 XTESTS_CALL(void) xtests_caseExceptionExpected(char const* exceptionType);
02378 
02379 
02380 XTESTS_CALL(int) xtests_floatingPointClose(double expected, double actual);
02381 
02388 XTESTS_CALL(double) xtests_setFloatingPointCloseFactor(double factor, double *old /* = NULL */);
02389 
02390 #endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
02391 
02392 /* /////////////////////////////////////////////////////////////////////////
02393  * C++-only functionality
02394  */
02395 
02396 #ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
02397 
02398 # if defined(__cplusplus) && \
02399      !defined(_XTESTS_NO_CPP_API)
02400 
02401 #  ifndef _XTESTS_NO_NAMESPACE
02402 namespace cpp
02403 {
02404 #  endif /* !_XTESTS_NO_NAMESPACE */
02405 
02406 
02407 template <typename T>
02408 struct xtests_failure_reporter;
02409 
02410 template <>
02411 struct xtests_failure_reporter<int>
02412 {
02413     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, int expected, int actual, xtests_comparison_t comp)
02414     {
02415         stlsoft_static_cast(void, xtests_testFailed_int(file, line, function, expr, expected, actual, comp));
02416     }
02417 };
02418 
02419 template <>
02420 struct xtests_failure_reporter<unsigned int>
02421 {
02422     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, unsigned int expected, unsigned int actual, xtests_comparison_t comp)
02423     {
02424         stlsoft_static_cast(void, xtests_testFailed_ulong(file, line, function, expr, static_cast<unsigned long>(expected), static_cast<unsigned long>(actual), comp));
02425     }
02426 };
02427 
02428 template <>
02429 struct xtests_failure_reporter<signed char>
02430 {
02431     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, signed char expected, signed char actual, xtests_comparison_t comp)
02432     {
02433         stlsoft_static_cast(void, xtests_failure_reporter<int>::xtests_report_failure_equal(file, line, function, expr, int(expected), int(actual), comp));
02434     }
02435 };
02436 
02437 template <>
02438 struct xtests_failure_reporter<unsigned char>
02439 {
02440     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, unsigned char expected, unsigned char actual, xtests_comparison_t comp)
02441     {
02442         stlsoft_static_cast(void, xtests_failure_reporter<int>::xtests_report_failure_equal(file, line, function, expr, int(expected), int(actual), comp));
02443     }
02444 };
02445 
02446 template <>
02447 struct xtests_failure_reporter<short>
02448 {
02449     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, int expected, int actual, xtests_comparison_t comp)
02450     {
02451         stlsoft_static_cast(void, xtests_failure_reporter<int>::xtests_report_failure_equal(file, line, function, expr, int(expected), int(actual), comp));
02452     }
02453 };
02454 
02455 template <>
02456 struct xtests_failure_reporter<unsigned short>
02457 {
02458     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, int expected, int actual, xtests_comparison_t comp)
02459     {
02460         stlsoft_static_cast(void, xtests_failure_reporter<int>::xtests_report_failure_equal(file, line, function, expr, int(expected), int(actual), comp));
02461     }
02462 };
02463 
02464 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
02465 template <>
02466 struct xtests_failure_reporter<stlsoft::uint32_t>
02467 {
02468     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, stlsoft::uint32_t expected, stlsoft::uint32_t actual, xtests_comparison_t comp)
02469     {
02470         stlsoft_static_cast(void, xtests_testFailed_int(file, line, function, expr, int(expected), int(actual), comp));
02471     }
02472 };
02473 #endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
02474 
02475 template <>
02476 struct xtests_failure_reporter<long>
02477 {
02478     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, long expected, long actual, xtests_comparison_t comp)
02479     {
02480         stlsoft_static_cast(void, xtests_testFailed_long(file, line, function, expr, expected, actual, comp));
02481     }
02482 };
02483 
02484 template <>
02485 struct xtests_failure_reporter<unsigned long>
02486 {
02487     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, unsigned long expected, unsigned long actual, xtests_comparison_t comp)
02488     {
02489         stlsoft_static_cast(void, xtests_testFailed_ulong(file, line, function, expr, expected, actual, comp));
02490     }
02491 };
02492 
02493 #  ifdef STLSOFT_CF_64BIT_INT_SUPPORT
02494 template <>
02495 struct xtests_failure_reporter< stlsoft_ns_qual(ss_sint64_t)>
02496 {
02497     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, stlsoft::sint64_t expected, stlsoft::sint64_t actual, xtests_comparison_t comp)
02498     {
02499         stlsoft_static_cast(void, xtests_testFailed_longlong(file, line, function, expr, expected, actual, comp));
02500     }
02501 };
02502 
02503 template <>
02504 struct xtests_failure_reporter< stlsoft_ns_qual(ss_uint64_t)>
02505 {
02506     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, stlsoft::uint64_t expected, stlsoft::uint64_t actual, xtests_comparison_t comp)
02507     {
02508         stlsoft_static_cast(void, xtests_testFailed_ulonglong(file, line, function, expr, expected, actual, comp));
02509     }
02510 };
02511 #  endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
02512 
02513 template <>
02514 struct xtests_failure_reporter<bool>
02515 {
02516     static void xtests_report_failure_equal(char const* file, int line, char const* function, char const* expr, int expected, int actual, xtests_comparison_t comp)
02517     {
02518         stlsoft_static_cast(void, xtests_testFailed_boolean(file, line, function, expr, expected, actual, comp));
02519     }
02520 };
02521 
02522 
02523 
02524 template<   typename T1
02525         ,   typename T2
02526         >
02527 struct xtests_integer_failure_reporter_selector
02528 {
02529 private:
02530     enum { are_types_same       =   (0 != stlsoft::is_same_type<T1, T2>::value) };
02531     enum { T1_is_larger_than_T2 =   sizeof(T1) > sizeof(T2)                     };
02532 
02533     typedef typename stlsoft::select_first_type_if< T1
02534                                                 ,   T2
02535                                                 ,   T1_is_larger_than_T2
02536                                                 >::type         larger_type_;
02537 
02538 public:
02539     typedef xtests_failure_reporter<larger_type_>               type;
02540 };
02541 
02542 template <typename I1, typename I2>
02543 inline void xtests_reportFailedIntegerComparison(char const* file, int line, char const* function, char const* expr, I1 const& expected, I2 const& actual, xtests_comparison_t comp)
02544 {
02545     STLSOFT_STATIC_ASSERT(0 != stlsoft::is_integral_type<I1>::value);
02546     STLSOFT_STATIC_ASSERT(0 != stlsoft::is_integral_type<I2>::value);
02547 
02548 #  if defined(STLSOFT_COMPILER_IS_BORLAND)
02549 
02550     xtests_integer_failure_reporter_selector<I1, I2>::type::xtests_report_failure_equal(file, line, function, expr, expected, actual, comp);
02551 
02552 #  else /* ? compiler */
02553 
02554     typedef typename xtests_integer_failure_reporter_selector<I1, I2>::type    failure_reporter_t;
02555 
02556     failure_reporter_t::xtests_report_failure_equal(file, line, function, expr, expected, actual, comp);
02557 
02558 #  endif /* compiler */
02559 }
02560 
02561 inline void xtests_reportFailedIntegerComparison(char const* file, int line, char const* function, char const* expr, bool expected, bool actual, xtests_comparison_t comp)
02562 {
02563 #  if defined(STLSOFT_COMPILER_IS_BORLAND)
02564 
02565     xtests_integer_failure_reporter_selector<bool, bool>::type::xtests_report_failure_equal(file, line, function, expr, expected, actual, comp);
02566 
02567 #  else /* ? compiler */
02568 
02569     typedef xtests_integer_failure_reporter_selector<bool, bool>::type    failure_reporter_t;
02570 
02571     failure_reporter_t::xtests_report_failure_equal(file, line, function, expr, expected, actual, comp);
02572 
02573 #  endif /* compiler */
02574 }
02575 
02576 #if 0
02577 inline void xtests_reportFailedIntegerComparison(char const* file, int line, char const* function, char const* expr, int expected, bool actual, xtests_comparison_t comp)
02578 {
02579     xtests_reportFailedIntegerComparison(file, line, function, expr, 0 != expected, actual, comp);
02580 }   
02581 #endif /* 0 */
02582 
02583 inline void xtests_reportFailedFloatingPointComparison(char const* file, int line, char const* function, char const* expr, double const& expected, double const& actual, xtests_comparison_t comp)
02584 {
02585     stlsoft_static_cast(void, xtests_testFailed_double(file, line, function, expr, expected, actual, comp));
02586 }
02587 
02588 template <typename I1, typename I2>
02589 inline int xtests_test_integer(char const* file, int line, char const* function, char const* expr, I1 const& expected, I2 const& actual, xtests_comparison_t comp)
02590 {
02591     int comparisonSucceeded = false;
02592 
02593     switch(comp)
02594     {
02595         case    xtestsComparisonEqual:
02596         case    xtestsComparisonApproxEqual:
02597             if(expected == actual)
02598             {
02599                 comparisonSucceeded = true;
02600             }
02601             break;
02602         case    xtestsComparisonNotEqual:
02603         case    xtestsComparisonApproxNotEqual:
02604             if(expected != actual)
02605             {
02606                 comparisonSucceeded = true;
02607             }
02608             break;
02609         case    xtestsComparisonGreaterThan:
02610             if(actual > expected)
02611             {
02612                 comparisonSucceeded = true;
02613             }
02614             break;
02615         case    xtestsComparisonLessThan:
02616             if(actual < expected)
02617             {
02618                 comparisonSucceeded = true;
02619             }
02620             break;
02621         case    xtestsComparisonGreaterThanOrEqual:
02622             if(actual >= expected)
02623             {
02624                 comparisonSucceeded = true;
02625             }
02626             break;
02627         case    xtestsComparisonLessThanOrEqual:
02628             if(actual <= expected)
02629             {
02630                 comparisonSucceeded = true;
02631             }
02632             break;
02633         case    xtestsComparison_max_enumerator:
02634             xtests_abend("invalid test comparison type: test framework may be out of date!");
02635             break;
02636     }
02637 
02638     if(comparisonSucceeded)
02639     {
02640         xtests_testPassed(file, line, function, expr);
02641     }
02642     else
02643     {
02644         xtests_reportFailedIntegerComparison(file, line, function, expr, expected, actual, comp);
02645     }
02646 
02647     return comparisonSucceeded;
02648 }
02649 
02650 inline int xtests_test_character(char const* file, int line, char const* function, char const* expr, char expected, char actual, xtests_comparison_t comp)
02651 {
02652     return xtests_testCharactersA(file, line, function, expr, expected, actual, comp);
02653 }
02654 inline int xtests_test_character(char const* file, int line, char const* function, char const* expr, wchar_t expected, wchar_t actual, xtests_comparison_t comp)
02655 {
02656     return xtests_testCharactersW(file, line, function, expr, expected, actual, comp);
02657 }
02658 
02659 inline int xtests_test_floating_point(char const* file, int line, char const* function, char const* expr, double const& expected, double const& actual, xtests_comparison_t comp)
02660 {
02661     int comparisonSucceeded = false;
02662 
02663     switch(comp)
02664     {
02665         case    xtestsComparisonEqual:
02666             if(expected == actual)
02667             {
02668                 comparisonSucceeded = true;
02669             }
02670             break;
02671         case    xtestsComparisonApproxEqual:
02672             if(xtests_floatingPointClose(expected, actual))
02673             {
02674                 comparisonSucceeded = true;
02675             }
02676             break;
02677         case    xtestsComparisonNotEqual:
02678             if(expected != actual)
02679             {
02680                 comparisonSucceeded = true;
02681             }
02682             break;
02683         case    xtestsComparisonApproxNotEqual:
02684             if(!xtests_floatingPointClose(expected, actual))
02685             {
02686                 comparisonSucceeded = true;
02687             }
02688             break;
02689         case    xtestsComparisonGreaterThan:
02690             if(actual > expected)
02691             {
02692                 comparisonSucceeded = true;
02693             }
02694             break;
02695         case    xtestsComparisonLessThan:
02696             if(actual < expected)
02697             {
02698                 comparisonSucceeded = true;
02699             }
02700             break;
02701         case    xtestsComparisonGreaterThanOrEqual:
02702             if(actual >= expected)
02703             {
02704                 comparisonSucceeded = true;
02705             }
02706             break;
02707         case    xtestsComparisonLessThanOrEqual:
02708             if(actual <= expected)
02709             {
02710                 comparisonSucceeded = true;
02711             }
02712             break;
02713         case    xtestsComparison_max_enumerator:
02714             xtests_abend("invalid test comparison type: test framework may be out of date!");
02715             break;
02716     }
02717 
02718     if(comparisonSucceeded)
02719     {
02720         stlsoft_static_cast(void, xtests_testPassed(file, line, function, expr));
02721     }
02722     else
02723     {
02724         stlsoft_static_cast(void, xtests_reportFailedFloatingPointComparison(file, line, function, expr, expected, actual, comp));
02725     }
02726 
02727     return comparisonSucceeded;
02728 }
02729 
02730 #  ifndef _XTESTS_NO_NAMESPACE
02731 } /* namespace cpp */
02732 #  endif /* !_XTESTS_NO_NAMESPACE */
02733 
02734 # endif /* __cplusplus) && !_XTESTS_NO_CPP_API */
02735 
02736 #endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
02737 
02738 /* /////////////////////////////////////////////////////////////////////////
02739  * Helper functions
02740  */
02741 
02742 #ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
02743 XTESTS_CALL(int) xtests_commandLine_parseVerbosity(int argc, char** argv, int *verbosity);
02744 #endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
02745 
02767 #define XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, pverbosity)                       \
02768                                                                                         \
02769     stlsoft_static_cast(void, XTESTS_NS_C_QUAL(xtests_commandLine_parseVerbosity)((argc), (argv), (pverbosity)))
02770 
02771 /* /////////////////////////////////////////////////////////////////////////
02772  * Obsolete names
02773  */
02774 
02775 #ifndef XTESTS_DOCUMENTATION_SKIP_SECTION
02776 # define XTESTS_FAIL_WITH_QUALIFIER(msg, qualifier)     XTESTS_TEST_FAIL_WITH_QUALIFIER(msg, qualifier)
02777 # define XTESTS_FAIL(msg)                               XTESTS_TEST_FAIL(msg)
02778 # define XTESTS_PASSED()                                XTESTS_TEST_PASSED()
02779 # define XTESTS_TEST_MULTIBYTE_STRINGS_EQUAL            XTESTS_TEST_MULTIBYTE_STRING_EQUAL
02780 #endif /* !XTESTS_DOCUMENTATION_SKIP_SECTION */
02781 
02782 /* /////////////////////////////////////////////////////////////////////////
02783  * Namespace
02784  */
02785 
02786 #ifndef _XTESTS_NO_NAMESPACE
02787 } /* namespace c */
02788 } /* namespace xtests */
02789 #endif /* !_XTESTS_NO_NAMESPACE */
02790 
02791 /* ////////////////////////////////////////////////////////////////////// */
02792 
02793 #endif /* !XTESTS_INCL_XTESTS_H_XTESTS */
02794 
02795 /* ////////////////////////////////////////////////////////////////////// */

xTests Library documentation © Matthew Wilson and Synesis Software Pty Ltd, 1999-2009 SourceForge.net Logo