#!/usr/bin/env python
Import('mlib_tests_env', 'user_options_dict', 'UnitTest')

lib_mlib_tests_env = mlib_tests_env.Clone()
bin_mlib_tests_env = mlib_tests_env.Clone()

lib_path  = user_options_dict['LIB_BUILD_DIR']
#bin_path  = user_options_dict['BIN_BUILD_DIR']

######
# lib
mlib_tests_lib_name = 'mlib_tests'
lib_src_files = [
                 'test_common.cpp',
                ]

# Precompiled header install
# :ATTENTION: if you use precompiled header in another project then point it out in
# SetPCH() function' argument 'additional_envs', like [bin_mlib_tests_env] here!
user_options_dict['SetPCH'](lib_mlib_tests_env, '_pc_.h', [bin_mlib_tests_env])

lib_mlib_tests_env.Library( target = lib_path +'/'+mlib_tests_lib_name, source = lib_src_files )

######
# bin

make_source_files = user_options_dict['make_source_files']

source_files = [
                'test_dataware.cpp',
                'test_instantiate.cpp',
                'test_iterator.cpp',
                'test_main.cpp',
                'test_ptr.cpp',
                'test_stream.cpp',
                'test_tech.cpp',
                'test_utils.cpp',

                # compiler benchmark test cases (uncomment if needed)
                #'profile_boost_lambda.cpp',   # 4.5: 9.57sec, 4.2: 14.75sec, clang 1.1/llvm 2.7: 6.00sec
                #'profile_boost_bind.cpp',     # 4.5: 4.60sec, 4.2: 4.76sec, clang 1.1/llvm 2.7: 4.04sec
                #'profile_boost_foreach.cpp',  # g++ 4.5: 3.15sec, g++ 4.2: 3.95sec, clang 1.1/llvm 2.7: 3.07sec
                #'profile_boost_function.cpp', # g++ 4.5: 3.20sec, g++ 4.2: 3.30sec, clang 1.1/llvm 2.7: 2.74sec
                #'profile_boost_range.cpp',    # 4.5: 4.27sec, 4.2: 6.60sec, clang 1.1/llvm 2.7: 3.48sec
                # Thomas Becker's: 4.5, 4.2: >6min.!, 1.1/llvm 2.7: fatal error after 30sec
                # Adobe's: 4.5: 9.30sec, 4.2: 18.30sec, 1.1/llvm 2.7: 6.27sec
                #'profile_any_iterator.cpp',

                'test_adobe_any_iterator.cpp',
               ]

# Boost.Foreach tests
source_files += make_source_files('foreach', '''
array_byref.cpp
array_byref_r.cpp
array_byval.cpp
array_byval_r.cpp
call_once.cpp
cstr_byref.cpp
cstr_byref_r.cpp
cstr_byval.cpp
cstr_byval_r.cpp
dependent_type.cpp
misc.cpp
noncopyable.cpp
pair_byref.cpp
pair_byref_r.cpp
pair_byval.cpp
pair_byval_r.cpp
rvalue_const.cpp
rvalue_const_r.cpp
rvalue_nonconst.cpp
rvalue_nonconst_r.cpp
stl_byref.cpp
stl_byref_r.cpp
stl_byval.cpp
stl_byval_r.cpp
user_defined.cpp
''') #utility.hpp

# any_iterator tests (replaced by adobe any_iterator)
#source_files += make_source_files('any_iterator', '''
#any_iterator_demo.cpp
#any_iterator_test.cpp
#any_iterator_wrapper_test.cpp
#boost_iterator_library_example_test.cpp
#test_any_iterator.cpp
#''')

# range adaptors' tests (Boost.Range)
source_files += make_source_files('range', '''
irange.cpp
adaptors.cpp
''') + make_source_files('range/adaptor_test', '''
adjacent_filtered.cpp
adjacent_filtered_example.cpp
copied.cpp
copied_example.cpp
filtered.cpp
filtered_example.cpp
indexed.cpp
indexed_example.cpp
indirected.cpp
indirected_example.cpp
map.cpp
map_keys_example.cpp
map_values_example.cpp
replaced.cpp
replaced_example.cpp
replaced_if.cpp
replaced_if_example.cpp
reversed.cpp
reversed_example.cpp
sliced.cpp
sliced_example.cpp
strided2.cpp
strided.cpp
strided_example.cpp
tokenized.cpp
transformed.cpp
transformed_example.cpp
uniqued.cpp
uniqued_example.cpp
''')

bin_mlib_tests_env.Prepend( LIBS = [mlib_tests_lib_name, 'MdLib'] )

test_prg_name = 'mlib_tests'
bin_mlib_tests_env.Program( target = test_prg_name, source = source_files )

UnitTest(test_prg_name, bin_mlib_tests_env)


