diff --git a/test/Jamfile b/test/Jamfile index dcfd359..162673b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,94 +1,72 @@ +# Copyright John Maddock 2004 +# +# There are two ways to invoke this Jamfile: +# +# If we pass the argument --type-traits-unit-test +# to bjam, then the tests are built as one big test +# program: this may be slightly quicker in some cases, +# but causes problems if any of the test sources don't compile. +# +# Alternatively, the default behaviour is to build each source +# file as a separate test program, these no longer depend upon Boost.Test +# (which causes cyclic dependencies). We also get a separate status report +# for each trait, which makes it easier to track down issues with non-conforming +# compilers. +# subproject libs/type_traits/test ; # bring in the rules for testing import testing ; - -rule type-traits-run ( sources + ) -{ - return [ - run - # sources - $(sources) - # dependencies - type_traits_init - ../../test/build/boost_unit_test_framework - : # additional args - --report_level=detailed --build_info=yes --log_level=messages - : # test-files - : # requirements - $(BOOST_ROOT) - : # test name - ] ; +# +# define the sources which need testing, mostly this is just +# all the files *_test.cpp, but any badly named examples can +# be added to this list :-) +# +TEST_SOURCES = [ GLOB . : *_test.cpp ] + udt_specialisations.cpp ; + +if --type-traits-unit-test in $(ARGV) +{ + test-suite type_traits : + [ run # sources: + $(TEST_SOURCES) + init.cpp + # dependencies + ../../test/build/boost_unit_test_framework + : # additional args + --report_level=detailed --build_info=yes --log_level=messages + : # test-files + : # requirements + $(BOOST_ROOT) + USE_UNIT_TEST=1 + : # test name + type_traits_test + ] ; + +} +else +{ + # this rule enumerates through all the sources and invokes + # the run rule for each source, the result is a list of all + # the run rules, which we can pass on to the test_suite rule: + rule test_all + { + #ECHO executing test_all rule ; + local all_rules = ; + for local file in $(TEST_SOURCES) + { + all_rules += [ run $(file) ] ; + } + #ECHO $(all_rules) ; + return $(all_rules) ; + } + + test-suite type_traits : + [ test_all r ] + ; # type traits suite + } -lib type_traits_init : init.cpp - : - $(BOOST_ROOT) - : -; - - -test-suite type_traits : - -[ type-traits-run add_const_test.cpp ] -[ type-traits-run add_pointer_test.cpp ] -[ type-traits-run add_reference_test.cpp ] -[ type-traits-run add_volatile_test.cpp ] -[ type-traits-run alignment_of_test.cpp ] -[ type-traits-run function_traits_test.cpp ] -[ type-traits-run has_nothrow_assign_test.cpp ] -[ type-traits-run has_nothrow_constr_test.cpp ] -[ type-traits-run has_nothrow_copy_test.cpp ] -[ type-traits-run has_trivial_assign_test.cpp ] -[ type-traits-run has_trivial_constr_test.cpp ] -[ type-traits-run has_trivial_copy_test.cpp ] -[ type-traits-run has_trivial_destructor_test.cpp ] -[ type-traits-run is_abstract_test.cpp ] -[ type-traits-run is_arithmetic_test.cpp ] -[ type-traits-run is_array_test.cpp ] -[ type-traits-run is_base_and_derived_test.cpp ] -[ type-traits-run is_class_test.cpp ] -[ type-traits-run is_compound_test.cpp ] -[ type-traits-run is_const_test.cpp ] -[ type-traits-run is_convertible_test.cpp ] -[ type-traits-run is_empty_test.cpp ] -[ type-traits-run is_enum_test.cpp ] -[ type-traits-run is_float_test.cpp ] -[ type-traits-run is_function_test.cpp ] -[ type-traits-run is_fundamental_test.cpp ] -[ type-traits-run is_integral_test.cpp ] -[ type-traits-run is_member_func_test.cpp ] -[ type-traits-run is_member_pointer_test.cpp ] -[ type-traits-run is_object_test.cpp ] -[ type-traits-run is_pod_test.cpp ] -[ type-traits-run is_pointer_test.cpp ] -[ type-traits-run is_polymorphic_test.cpp ] -[ type-traits-run is_reference_test.cpp ] -[ type-traits-run is_same_test.cpp ] -[ type-traits-run is_scalar_test.cpp ] -[ type-traits-run is_stateless_test.cpp ] -[ type-traits-run is_union_test.cpp ] -[ type-traits-run is_void_test.cpp ] -[ type-traits-run is_volatile_test.cpp ] -[ type-traits-run remove_bounds_test.cpp ] -[ type-traits-run remove_const_test.cpp ] -[ type-traits-run remove_cv_test.cpp ] -[ type-traits-run remove_pointer_test.cpp ] -[ type-traits-run remove_reference_test.cpp ] -[ type-traits-run remove_volatile_test.cpp ] -[ type-traits-run tricky_abstract_type_test.cpp ] -[ type-traits-run tricky_add_pointer_test.cpp ] -[ type-traits-run tricky_function_type_test.cpp ] -[ type-traits-run tricky_incomplete_type_test.cpp ] -[ type-traits-run tricky_is_enum_test.cpp ] -[ type-traits-run tricky_partial_spec_test.cpp ] -[ type-traits-run type_with_alignment_test.cpp ] -[ type-traits-run udt_specialisations.cpp ] - -; # type traits suite - - - diff --git a/test/check_integral_constant.hpp b/test/check_integral_constant.hpp index ab70d07..5258c79 100644 --- a/test/check_integral_constant.hpp +++ b/test/check_integral_constant.hpp @@ -7,7 +7,11 @@ #ifndef BOOST_CHECK_INTEGRAL_CONSTANT_HPP #define BOOST_CHECK_INTEGRAL_CONSTANT_HPP +#ifdef USE_UNIT_TEST #include +#else +#include "test.hpp" +#endif namespace boost{ namespace detail{ diff --git a/test/check_type.hpp b/test/check_type.hpp index fefbd08..700551a 100644 --- a/test/check_type.hpp +++ b/test/check_type.hpp @@ -7,7 +7,11 @@ #ifndef BOOST_CHECK_TYPE_HPP #define BOOST_CHECK_TYPE_HPP +#ifdef USE_UNIT_TEST #include +#else +#include "test.hpp" +#endif #include /* diff --git a/test/test.hpp b/test/test.hpp index 4342d27..547d4d0 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -7,7 +7,17 @@ #ifndef TT_TEST_HPP #define TT_TEST_HPP -#include +#ifdef USE_UNIT_TEST +# include +#endif +#include +#include +#include + +#ifdef __BORLANDC__ +// we have to turn off these warnings overwise we get swamped by the things: +#pragma option -w-8008 -w-8066 +#endif // // basic configuration: @@ -30,6 +40,7 @@ #endif +#ifdef USE_UNIT_TEST // // global unit, this is not safe, but until the unit test framework uses // shared_ptr throughout this is about as good as it gets :-( @@ -56,6 +67,47 @@ public: #define TT_TEST_END }} +#else + +// +// replacements for Unit test macros: +// +int error_count = 0; + +#define BOOST_CHECK_MESSAGE(pred, message)\ + do{\ + if(!(pred))\ + {\ + std::cerr << __FILE__ << ":" << __LINE__ << ": " << message << std::endl;\ + ++error_count;\ + }\ + }while(0) + +#define BOOST_WARN_MESSAGE(pred, message)\ + do{\ + if(!(pred))\ + {\ + std::cerr << __FILE__ << ":" << __LINE__ << ": " << message << std::endl;\ + }\ + }while(0) + +#define BOOST_MESSAGE(message)\ + do{ std::cout << __FILE__ << ":" << __LINE__ << ": " << message << std::endl; }while(0) + +#define BOOST_CHECK(pred)\ + do{ \ + if(!(pred)){\ + std::cout << __FILE__ << ":" << __LINE__ << ": Error in " << BOOST_STRINGIZE(pred) << std::endl;\ + ++error_count;\ + } \ + }while(0) + +#define TT_TEST_BEGIN(trait_name)\ + int main(){ +#define TT_TEST_END return error_count; } + +#endif + #define TRANSFORM_CHECK(name, from_suffix, to_suffix)\ BOOST_CHECK_TYPE(bool to_suffix, name::type);\ BOOST_CHECK_TYPE(char to_suffix, name::type);\ diff --git a/test/tricky_partial_spec_test.cpp b/test/tricky_partial_spec_test.cpp index c47c0a0..20d86c2 100644 --- a/test/tricky_partial_spec_test.cpp +++ b/test/tricky_partial_spec_test.cpp @@ -18,6 +18,8 @@ #include #include #endif +#include +#include // // VC++ emits an awful lot of warnings unless we define these: