trait.hpp: Format.

2006-07-06  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/util/regression/trait/assoc/trait.hpp: Format.
	* testsuite/util/regression/rand/priority_queue/
	rand_regression_test.hpp: Same.
	* testsuite/util/regression/rand/assoc/rand_regression_test.hpp: Same.
	* testsuite/util/regression/rand/
	assoc/container_rand_regression_test.hpp: Same.
	* testsuite/util/regression/priority_queue/common_type.hpp: Same.
	* testsuite/util/regression/assoc/common_type.hpp: Same.
	* testsuite/util/regression/basic_type.hpp: Same.

From-SVN: r115226
This commit is contained in:
Benjamin Kosnik 2006-07-06 17:45:13 +00:00 committed by Benjamin Kosnik
parent cec12c7a9b
commit 55a4c999b5
8 changed files with 707 additions and 880 deletions

View File

@ -1,4 +1,16 @@
2006-07-05 Benjamin Kosnik <bkoz@redhat.com>
2006-07-06 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/util/regression/trait/assoc/trait.hpp: Format.
* testsuite/util/regression/rand/priority_queue/
rand_regression_test.hpp: Same.
* testsuite/util/regression/rand/assoc/rand_regression_test.hpp: Same.
* testsuite/util/regression/rand/
assoc/container_rand_regression_test.hpp: Same.
* testsuite/util/regression/priority_queue/common_type.hpp: Same.
* testsuite/util/regression/assoc/common_type.hpp: Same.
* testsuite/util/regression/basic_type.hpp: Same.
2006-07-05 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (pch_output): New.
(clean-local): Use it.

View File

@ -52,210 +52,93 @@
namespace pb_ds
{
namespace test
{
typedef dbg_ex_allocator<basic_type> alloc_type;
namespace test
struct hash
{
typedef alloc_type::rebind<basic_type>::other::const_reference const_key_reference;
typedef
pb_ds::test::dbg_ex_allocator<
pb_ds::test::basic_type>
alloc_type;
struct hash
size_t
operator()(const_key_reference r_key) const
{
typedef
alloc_type::rebind<
pb_ds::test::basic_type>::other::const_reference
const_key_reference;
size_t ret = 0;
typedef basic_type::const_iterator const_iterator;
for (const_iterator it = r_key.begin(); it != r_key.end(); ++it)
ret = ret * 5 + static_cast<size_t>(*it);
return ret;
}
};
size_t
operator()(const_key_reference r_key) const
{
size_t ret = 0;
typedef pb_ds::string_trie_e_access_traits<basic_type, 'a', 'a' + basic_type::distinct_chars - 1, false, alloc_type> e_access_traits_t;
for (pb_ds::test::basic_type::const_iterator it = r_key.begin(); it != r_key.end(); ++it)
ret = ret* 5 + static_cast<size_t>(*it);
template<typename Data_Type>
struct tree_types
{
private:
typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, pb_ds::null_tree_node_update, alloc_type>::regression_tl no_order_statistics_tl_t;
return (ret);
}
};
typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, pb_ds::tree_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t;
typedef
pb_ds::string_trie_e_access_traits<
basic_type,
'a',
'a' + basic_type::distinct_chars - 1,
false,
alloc_type>
e_access_traits_t;
public:
typedef typename pb_ds::detail::typelist_append<no_order_statistics_tl_t, order_statistics_tl_t>::type tl_t;
template<typename Data_Type>
struct tree_types
{
private:
typedef
typename pb_ds::test::tree_common_types<
pb_ds::test::basic_type,
Data_Type,
std::less<
pb_ds::test::basic_type>,
pb_ds::null_tree_node_update,
alloc_type>::regression_tl
no_order_statistics_tl_t;
typedef no_order_statistics_tl_t min_tl_t;
};
typedef
typename pb_ds::test::tree_common_types<
pb_ds::test::basic_type,
Data_Type,
std::less<
pb_ds::test::basic_type>,
pb_ds::tree_order_statistics_node_update,
alloc_type>::regression_tl
order_statistics_tl_t;
template<typename Data_Type>
struct trie_types
{
private:
typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, pb_ds::pat_trie_tag, pb_ds::null_trie_node_update, alloc_type>::regression_tl no_updates_tl_t;
public:
typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, pb_ds::pat_trie_tag, pb_ds::trie_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t;
typedef
typename pb_ds::detail::typelist_append<
no_order_statistics_tl_t,
order_statistics_tl_t>::type
tl_t;
typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, pb_ds::pat_trie_tag, pb_ds::trie_prefix_search_node_update, alloc_type>::regression_tl prefix_search_tl_t;
typedef no_order_statistics_tl_t min_tl_t;
};
public:
typedef typename pb_ds::detail::typelist_append<no_updates_tl_t, typename pb_ds::detail::typelist_append<prefix_search_tl_t, order_statistics_tl_t>::type>::type tl_t;
template<typename Data_Type>
struct trie_types
{
private:
typedef
typename pb_ds::test::trie_common_types<
pb_ds::test::basic_type,
Data_Type,
e_access_traits_t,
pb_ds::pat_trie_tag,
pb_ds::null_trie_node_update,
alloc_type>::regression_tl
no_updates_tl_t;
typedef no_updates_tl_t min_tl_t;
};
typedef
typename pb_ds::test::trie_common_types<
pb_ds::test::basic_type,
Data_Type,
e_access_traits_t,
pb_ds::pat_trie_tag,
pb_ds::trie_order_statistics_node_update,
alloc_type>::regression_tl
order_statistics_tl_t;
template<typename Data_Type>
struct hash_types
{
typedef typename hash_common_types<basic_type, Data_Type, hash, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t;
typedef
typename pb_ds::test::trie_common_types<
pb_ds::test::basic_type,
Data_Type,
e_access_traits_t,
pb_ds::pat_trie_tag,
pb_ds::trie_prefix_search_node_update,
alloc_type>::regression_tl
prefix_search_tl_t;
typedef tl_t min_tl_t;
};
public:
typedef
typename pb_ds::detail::typelist_append<
no_updates_tl_t,
typename pb_ds::detail::typelist_append<
prefix_search_tl_t,
order_statistics_tl_t>::type>::type
tl_t;
template<typename Data_Type>
struct lu_types
{
typedef typename lu_common_types<basic_type, Data_Type, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t;
typedef no_updates_tl_t min_tl_t;
};
typedef tl_t min_tl_t;
};
template<typename Data_Type>
struct hash_types
{
typedef
typename pb_ds::test::hash_common_types<
pb_ds::test::basic_type,
Data_Type,
hash,
std::equal_to<
pb_ds::test::basic_type>,
alloc_type>::regression_tl
tl_t;
typedef tree_types<null_mapped_type>::tl_t tree_set_tl_t;
typedef tree_types<null_mapped_type>::min_tl_t min_tree_set_tl_t;
typedef tree_types<basic_type>::tl_t tree_map_tl_t;
typedef tree_types<basic_type>::min_tl_t min_tree_map_tl_t;
typedef tl_t min_tl_t;
};
typedef hash_types<null_mapped_type>::tl_t hash_set_tl_t;
typedef hash_types<null_mapped_type>::min_tl_t min_hash_set_tl_t;
typedef hash_types<basic_type>::tl_t hash_map_tl_t;
typedef hash_types<basic_type>::min_tl_t min_hash_map_tl_t;
template<typename Data_Type>
struct lu_types
{
typedef
typename pb_ds::test::lu_common_types<
pb_ds::test::basic_type,
Data_Type,
std::equal_to<
pb_ds::test::basic_type>,
alloc_type>::regression_tl
tl_t;
typedef tl_t min_tl_t;
};
typedef
tree_types<
pb_ds::null_mapped_type>::tl_t
tree_set_tl_t;
typedef
tree_types<
pb_ds::null_mapped_type>::min_tl_t
min_tree_set_tl_t;
typedef
hash_types<
pb_ds::null_mapped_type>::tl_t
hash_set_tl_t;
typedef
hash_types<
pb_ds::null_mapped_type>::min_tl_t
min_hash_set_tl_t;
typedef lu_types< pb_ds::null_mapped_type>::tl_t lu_set_tl_t;
typedef
lu_types<
pb_ds::null_mapped_type>::min_tl_t
min_lu_set_tl_t;
typedef
trie_types<
pb_ds::null_mapped_type>::tl_t
trie_set_tl_t;
typedef
trie_types<
pb_ds::null_mapped_type>::min_tl_t
min_trie_set_tl_t;
typedef tree_types< basic_type>::tl_t tree_map_tl_t;
typedef tree_types< basic_type>::min_tl_t min_tree_map_tl_t;
typedef hash_types< basic_type>::tl_t hash_map_tl_t;
typedef hash_types< basic_type>::min_tl_t min_hash_map_tl_t;
typedef lu_types< basic_type>::tl_t lu_map_tl_t;
typedef lu_types< basic_type>::min_tl_t min_lu_map_tl_t;
typedef trie_types< basic_type>::tl_t trie_map_tl_t;
typedef trie_types< basic_type>::min_tl_t min_trie_map_tl_t;
} // namespace test
typedef lu_types<null_mapped_type>::tl_t lu_set_tl_t;
typedef lu_types<null_mapped_type>::min_tl_t min_lu_set_tl_t;
typedef lu_types<basic_type>::tl_t lu_map_tl_t;
typedef lu_types<basic_type>::min_tl_t min_lu_map_tl_t;
typedef trie_types<null_mapped_type>::tl_t trie_set_tl_t;
typedef trie_types<null_mapped_type>::min_tl_t min_trie_set_tl_t;
typedef trie_types<basic_type>::tl_t trie_map_tl_t;
typedef trie_types<basic_type>::min_tl_t min_trie_map_tl_t;
} // namespace test
} // namespace pb_ds
#endif // #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP

View File

@ -52,67 +52,52 @@
namespace pb_ds
{
namespace test
{
#define PB_DS_BASE_C_DEC \
std::basic_string<char, std::char_traits<char>, dbg_ex_allocator<char> >
namespace test
struct basic_type : public PB_DS_BASE_C_DEC
{
private:
typedef PB_DS_BASE_C_DEC base_type;
#define PB_DS_BASE_C_DEC \
std::basic_string< \
char, \
std::char_traits< \
char>, \
dbg_ex_allocator< \
char> >
public:
enum
{
distinct_chars = 4
};
struct basic_type : public PB_DS_BASE_C_DEC
basic_type() { }
template<typename Gen>
basic_type(Gen& r_gen, size_t max)
{
public:
enum
size_t rnd = r_gen.get_unsigned_long(0, static_cast<unsigned long>(max));
while (rnd > 0)
{
distinct_chars = 4
};
base_type::push_back('a' + static_cast<char>(rnd % distinct_chars));
rnd /= distinct_chars;
}
}
public:
basic_type()
{ }
basic_type(const std::string other)
{
std::string::const_iterator it = other.begin();
while (it != other.end())
{
base_type::push_back(*it);
++it;
}
}
template<typename Gen>
basic_type(Gen& r_gen, size_t max)
{
size_t rnd =
r_gen.get_unsigned_long(0, static_cast<unsigned long>(max));
while (rnd > 0)
{
PB_DS_BASE_C_DEC::push_back('a' +
static_cast<char>(rnd % distinct_chars));
rnd /= distinct_chars;
}
}
basic_type(const std::string other)
{
std::string::const_iterator it = other.begin();
while (it != other.end())
{
PB_DS_BASE_C_DEC::push_back(*it);
++it;
}
}
operator std::string() const
{
return (std::string(PB_DS_BASE_C_DEC::c_str()));
}
};
operator std::string() const
{ return std::string(base_type::c_str());}
};
#undef PB_DS_BASE_C_DEC
} // namespace test
} // namespace test
} // namespace pb_ds
#endif // #ifndef PB_DS_BASIC_TYPE_HPP

View File

@ -52,27 +52,14 @@
namespace pb_ds
{
namespace test
{
typedef dbg_ex_allocator<basic_type> alloc_type;
namespace test
{
typedef
pb_ds::test::dbg_ex_allocator<
pb_ds::test::basic_type>
alloc_type;
typedef
pb_ds::test::pq_common_types<
pb_ds::test::basic_type,
std::less<
pb_ds::test::basic_type>,
alloc_type>::regression_tl
pq_tl_t;
typedef pq_tl_t min_pq_tl_t;
} // namespace test
typedef pq_common_types<basic_type, std::less<basic_type>, alloc_type>::regression_tl pq_tl_t;
typedef pq_tl_t min_pq_tl_t;
} // namespace test
} // namespace pb_ds
#endif // #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP
#endif

View File

@ -60,433 +60,433 @@
namespace pb_ds
{
namespace test
{
namespace detail
{
namespace test
{
namespace detail
{
#ifdef PB_DS_REGRESSION_TRACE
#define PB_DS_TRACE(X) std::cerr << X << std::endl
#else // #ifdef PB_DS_REGRESSION_TRACE
#else
#define PB_DS_TRACE(X)
#endif // #ifdef PB_DS_REGRESSION_TRACE
#endif
#define PB_DS_CLASS_T_DEC \
template<typename Cntnr>
#define PB_DS_CLASS_T_DEC \
template<typename Cntnr>
#define PB_DS_CLASS_C_DEC \
container_rand_regression_test< \
Cntnr>
#define PB_DS_CLASS_C_DEC \
container_rand_regression_test<Cntnr>
#define PB_DS_COND_COMPARE(L, R) \
if (m_g.get_prob() < m_mp) \
cmp(L, R, __FUNCTION__);
#define PB_DS_COND_COMPARE(L, R) \
if (m_g.get_prob() < m_mp) \
cmp(L, R, __FUNCTION__);
#define PB_DS_RUN_MTHD(MTHD) \
{ \
bool done = false; \
#define PB_DS_RUN_MTHD(MTHD) \
{ \
bool done = false; \
\
while (!done) \
done = MTHD(); \
}
while (!done) \
done = MTHD(); \
}
#define PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, F, L) \
if (!(PRED)) \
{ \
std::cerr << "Failure at " << F << ": " << L << std::endl; \
\
std::cerr << MORE << std::endl; \
\
std::cerr << "container:" << std::endl; \
\
print_container(*(P_C)); \
std::cerr << std::endl; \
\
std::cerr << "native container:" << std::endl; \
\
print_container(*(P_NC)); \
std::cerr << std::endl; \
\
throw std::logic_error("fucked!"); \
}
#define PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, F, L) \
if (!(PRED)) \
{ \
std::cerr << "Failure at " << F << ": " << L << std::endl; \
std::cerr << MORE << std::endl; \
std::cerr << "container:" << std::endl; \
print_container(*(P_C)); \
std::cerr << std::endl; \
std::cerr << "native container:" << std::endl; \
print_container(*(P_NC)); \
std::cerr << std::endl; \
throw std::logic_error("fucked!"); \
}
#define PB_DS_THROW_IF_FAILED(PRED, MORE, P_C, P_NC) \
PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__)
PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__)
#define PB_DS_SET_DESTRUCT_PRINT \
destructor_printer dest_print___(__FUNCTION__);
#define PB_DS_SET_DESTRUCT_PRINT \
destructor_printer dest_print___(__FUNCTION__);
#define PB_DS_CANCEL_DESTRUCT_PRINT \
dest_print___.cancel_print();
#define PB_DS_CANCEL_DESTRUCT_PRINT \
dest_print___.cancel_print();
// Rand test specialized for a specific container.
template<typename Cntnr>
class container_rand_regression_test
// Rand test specialized for a specific container.
template<typename Cntnr>
class container_rand_regression_test
{
public:
container_rand_regression_test(unsigned long, size_t, size_t, double,
double, double, double, double, bool);
virtual
~container_rand_regression_test();
void
operator()();
private:
typedef Cntnr cntnr;
typedef typename cntnr::allocator allocator;
typedef typename cntnr::size_type size_type;
typedef twister_rand_gen gen;
typedef regression_test_traits<Cntnr> test_traits;
typedef pb_ds::container_traits<Cntnr> container_traits;
typedef typename test_traits::key_type key_type;
typedef typename test_traits::const_key_reference const_key_reference;
typedef typename test_traits::value_type value_type;
typedef typename test_traits::native_type native_type;
enum op
{
public:
container_rand_regression_test(unsigned long seed, size_t n, size_t m, double tp, double ip, double ep, double cp, double mp, bool disp);
virtual
~container_rand_regression_test();
void
operator()();
private:
typedef Cntnr cntnr;
typedef typename cntnr::allocator allocator;
typedef typename cntnr::size_type size_type;
typedef twister_rand_gen gen;
typedef regression_test_traits< Cntnr> test_traits;
typedef pb_ds::container_traits< Cntnr> container_traits;
typedef typename test_traits::key_type key_type;
typedef typename test_traits::const_key_reference const_key_reference;
typedef typename test_traits::value_type value_type;
typedef typename test_traits::native_type native_type;
enum op
{
insert_op,
erase_op,
clear_op,
other_op
};
typedef dbg_ex_allocator< char> alloc_t;
private:
op
get_next_op();
size_t
get_next_sub_op(size_t max);
static void
defs();
static void
key_defs();
static void
mapped_defs();
static void
value_defs();
static void
ds_defs();
static void
iterator_defs();
static void
node_iterator_defs(pb_ds::detail::false_type);
static void
node_iterator_defs(pb_ds::detail::true_type);
static void
policy_defs();
static void
policy_defs(pb_ds::basic_hash_tag);
static void
policy_defs(pb_ds::cc_hash_tag);
static void
policy_defs(pb_ds::gp_hash_tag);
static void
policy_defs(pb_ds::tree_tag);
static void
policy_defs(pb_ds::list_update_tag);
static void
policy_defs(pb_ds::pat_trie_tag);
void
policy_access();
void
policy_access(pb_ds::basic_hash_tag);
void
policy_access(pb_ds::cc_hash_tag);
void
policy_access(pb_ds::gp_hash_tag);
void
policy_access(pb_ds::tree_tag);
void
policy_access(pb_ds::list_update_tag);
void
policy_access(pb_ds::pat_trie_tag);
void
it_copy();
void
it_assign();
void
rev_it_copy();
void
rev_it_assign();
void
rev_it_copy_imp(pb_ds::detail::false_type);
void
rev_it_copy_imp(pb_ds::detail::true_type);
void
rev_it_assign_imp(pb_ds::detail::false_type);
void
rev_it_assign_imp(pb_ds::detail::true_type);
bool
default_constructor();
void
swap();
bool
copy_constructor();
bool
assignment_operator();
bool
it_constructor();
bool
it_constructor_imp(pb_ds::cc_hash_tag);
bool
it_constructor_imp(pb_ds::gp_hash_tag);
bool
it_constructor_imp(pb_ds::tree_tag);
bool
it_constructor_imp(pb_ds::list_update_tag);
bool
it_constructor_imp(pb_ds::pat_trie_tag);
bool
insert();
bool
erase();
bool
erase_it();
bool
erase_it_imp(pb_ds::detail::false_type);
bool
erase_it_imp(pb_ds::detail::true_type);
bool
erase_rev_it();
bool
erase_rev_it_imp(pb_ds::detail::false_type);
bool
erase_rev_it_imp(pb_ds::detail::true_type);
bool
erase_if();
bool
clear();
bool
resize();
bool
resize_imp(pb_ds::detail::true_type);
bool
resize_imp(pb_ds::detail::false_type);
bool
get_set_loads();
bool
get_set_loads_imp(pb_ds::detail::true_type);
bool
get_set_loads_imp(pb_ds::detail::false_type);
void
get_set_load();
void
get_set_load_imp(pb_ds::detail::true_type);
void
get_set_load_imp(pb_ds::detail::false_type);
bool
subscript();
bool
subscript_imp(pb_ds::detail::false_type);
bool
subscript_imp(pb_ds::detail::true_type);
bool
split_join();
bool
split_join_imp(pb_ds::detail::false_type);
bool
split_join_imp(pb_ds::detail::true_type);
void
cmp(const Cntnr& r_container, const native_type& r_native_c, const std::string& r_call_fn);
void
basic_cmp_(const Cntnr& r_container, const native_type& r_native_c);
void
cmp_(const Cntnr& r_container, const native_type& r_native_c);
void
order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
void
order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
void
back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
void
back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
void
reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
void
reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
void
order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
void
order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
void
prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
void
prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
template<typename Const_It, class Const_Native_It>
void
it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, Const_Native_It native_e);
template<typename Const_It, class Const_Native_It>
void
back_it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, Const_Native_It native_e);
void
lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
void
lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
void
upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
void
upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
void
print_container(const native_type& r_cnt, std::ostream& r_os = std::cerr) const;
void
print_container(const cntnr& r_cnt, std::ostream& r_os = std::cerr) const;
private:
struct destructor_printer
{
destructor_printer(const std::string& r_msg) : m_msg(r_msg),
m_print(true)
{ }
void
cancel_print()
{
m_print = false;
}
~destructor_printer()
{
if (!m_print)
return;
std::cerr << std::endl <<
"Uncaught exception: " << std::endl <<
m_msg << std::endl;
}
private:
const std::string m_msg;
bool m_print;
};
private:
const unsigned long m_seed;
const size_t m_n;
const size_t m_m;
const double m_tp;
const double m_ip;
const double m_ep;
const double m_cp;
const double m_mp;
const bool m_disp;
twister_rand_gen m_g;
Cntnr* m_p_c;
native_type m_native_c;
alloc_t m_alloc;
size_t m_i;
insert_op,
erase_op,
clear_op,
other_op
};
typedef dbg_ex_allocator<char> alloc_t;
private:
op
get_next_op();
size_t
get_next_sub_op(size_t);
static void
defs();
static void
key_defs();
static void
mapped_defs();
static void
value_defs();
static void
ds_defs();
static void
iterator_defs();
static void
node_iterator_defs(pb_ds::detail::false_type);
static void
node_iterator_defs(pb_ds::detail::true_type);
static void
policy_defs();
static void
policy_defs(pb_ds::basic_hash_tag);
static void
policy_defs(pb_ds::cc_hash_tag);
static void
policy_defs(pb_ds::gp_hash_tag);
static void
policy_defs(pb_ds::tree_tag);
static void
policy_defs(pb_ds::list_update_tag);
static void
policy_defs(pb_ds::pat_trie_tag);
void
policy_access();
void
policy_access(pb_ds::basic_hash_tag);
void
policy_access(pb_ds::cc_hash_tag);
void
policy_access(pb_ds::gp_hash_tag);
void
policy_access(pb_ds::tree_tag);
void
policy_access(pb_ds::list_update_tag);
void
policy_access(pb_ds::pat_trie_tag);
void
it_copy();
void
it_assign();
void
rev_it_copy();
void
rev_it_assign();
void
rev_it_copy_imp(pb_ds::detail::false_type);
void
rev_it_copy_imp(pb_ds::detail::true_type);
void
rev_it_assign_imp(pb_ds::detail::false_type);
void
rev_it_assign_imp(pb_ds::detail::true_type);
bool
default_constructor();
void
swap();
bool
copy_constructor();
bool
assignment_operator();
bool
it_constructor();
bool
it_constructor_imp(pb_ds::cc_hash_tag);
bool
it_constructor_imp(pb_ds::gp_hash_tag);
bool
it_constructor_imp(pb_ds::tree_tag);
bool
it_constructor_imp(pb_ds::list_update_tag);
bool
it_constructor_imp(pb_ds::pat_trie_tag);
bool
insert();
bool
erase();
bool
erase_it();
bool
erase_it_imp(pb_ds::detail::false_type);
bool
erase_it_imp(pb_ds::detail::true_type);
bool
erase_rev_it();
bool
erase_rev_it_imp(pb_ds::detail::false_type);
bool
erase_rev_it_imp(pb_ds::detail::true_type);
bool
erase_if();
bool
clear();
bool
resize();
bool
resize_imp(pb_ds::detail::true_type);
bool
resize_imp(pb_ds::detail::false_type);
bool
get_set_loads();
bool
get_set_loads_imp(pb_ds::detail::true_type);
bool
get_set_loads_imp(pb_ds::detail::false_type);
void
get_set_load();
void
get_set_load_imp(pb_ds::detail::true_type);
void
get_set_load_imp(pb_ds::detail::false_type);
bool
subscript();
bool
subscript_imp(pb_ds::detail::false_type);
bool
subscript_imp(pb_ds::detail::true_type);
bool
split_join();
bool
split_join_imp(pb_ds::detail::false_type);
bool
split_join_imp(pb_ds::detail::true_type);
void
cmp(const Cntnr&, const native_type&, const std::string&);
void
basic_cmp_(const Cntnr&, const native_type&);
void
cmp_(const Cntnr&, const native_type&);
void
order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void
order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void
back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void
back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void
reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void
reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void
order_statistics_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void
order_statistics_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void
prefix_search_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void
prefix_search_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
template<typename Const_It, class Const_Native_It>
void
it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It);
template<typename Const_It, class Const_Native_It>
void
back_it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It);
void
lower_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void
lower_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void
upper_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void
upper_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void
print_container(const native_type&, std::ostream& r_os = std::cerr) const;
void
print_container(const cntnr&, std::ostream& r_os = std::cerr) const;
private:
struct destructor_printer
{
destructor_printer(const std::string& r_msg)
: m_msg(r_msg), m_print(true) { }
void
cancel_print()
{ m_print = false; }
~destructor_printer()
{
if (!m_print)
return;
std::cerr << std::endl << "Uncaught exception: " << std::endl
<< m_msg << std::endl;
}
private:
const std::string m_msg;
bool m_print;
};
private:
const unsigned long m_seed;
const size_t m_n;
const size_t m_m;
const double m_tp;
const double m_ip;
const double m_ep;
const double m_cp;
const double m_mp;
const bool m_disp;
twister_rand_gen m_g;
Cntnr* m_p_c;
native_type m_native_c;
alloc_t m_alloc;
size_t m_i;
};
#include <regression/rand/assoc/detail/constructor_destructor_fn_imps.hpp>
#include <regression/rand/assoc/detail/cmp_fn_imps.hpp>
#include <regression/rand/assoc/detail/operator_fn_imps.hpp>
@ -504,27 +504,17 @@ namespace pb_ds
#include <regression/rand/assoc/detail/diagnostic_fn_imps.hpp>
#undef PB_DS_COND_COMPARE
#undef PB_DS_RUN_MTHD
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
#undef PB_DS_THROW_IF_FAILED_
#undef PB_DS_THROW_IF_FAILED
#undef PB_DS_SET_DESTRUCT_PRINT
#undef PB_DS_CANCEL_DESTRUCT_PRINT
#undef PB_DS_TRACE
} // namespace detail
} // namespace test
} // namespace detail
} // namespace test
} // namespace pb_ds
#endif // #ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_HPP
#endif

View File

@ -44,6 +44,9 @@
* Contains a random-operation test.
*/
#ifndef PB_DS_ASSOC_RAND_REGRESSION_TEST_HPP
#define PB_DS_ASSOC_RAND_REGRESSION_TEST_HPP
#include <iostream>
#include <vector>
#include <regression/rand/assoc/container_rand_regression_test.hpp>
@ -120,12 +123,12 @@ namespace detail
{
detail::verify_params(sd, n, m, tp, ip, ep, cp, mp, disp);
}
catch(pb_ds::test::illegal_input_error&)
catch (pb_ds::test::illegal_input_error&)
{
detail::usage(name);
return -1;
}
catch(...)
catch (...)
{
return -2;
};
@ -204,3 +207,4 @@ namespace detail
} // namespace test
} // namespace pb_ds
#endif

View File

@ -44,6 +44,9 @@
* Contains a random-operation test.
*/
#ifndef PB_DS_PQ_RAND_REGRESSION_TEST_HPP
#define PB_DS_PQ_RAND_REGRESSION_TEST_HPP
#include <iostream>
#include <vector>
#include <regression/rand/priority_queue/container_rand_regression_test.hpp>
@ -208,3 +211,4 @@ namespace detail
} // namespace test
} // namespace pb_ds
#endif

View File

@ -59,231 +59,193 @@
namespace pb_ds
{
namespace test
{
namespace detail
{
namespace test
#define PB_DS_CLASS_T_DEC \
template<typename Cntnr>
#define PB_DS_CLASS_C_DEC \
regression_test_traits<Cntnr>
#define PB_DS_TYPE_TRAITS_C_DEC \
regression_test_type_traits<Cntnr>
#define PB_DS_NATIVE_TYPE_TRAITS_C_DEC \
native_type_traits<typename PB_DS_TYPE_TRAITS_C_DEC::key_type, \
typename PB_DS_TYPE_TRAITS_C_DEC::mapped_type, \
typename Cntnr::allocator>
#define PB_DS_RESIZE_TRAITS_C_DEC \
regression_test_resize_traits<Cntnr, typename Cntnr::container_category>
#define PB_DS_SET_LOADS_TRAITS_C_DEC \
regression_test_get_set_loacontainer_traits<Cntnr, \
typename Cntnr::container_category>
#define PB_DS_SET_LOAD_TRAITS_C_DEC \
regression_test_get_set_load_traits<Cntnr,typename Cntnr::container_category>
#define PB_DS_NODE_UPDATOR_TRAITS_C_DEC \
regression_test_node_update_traits<Cntnr, typename Cntnr::container_category>
template<typename Cntnr>
struct regression_test_traits : private PB_DS_TYPE_TRAITS_C_DEC,
private PB_DS_NATIVE_TYPE_TRAITS_C_DEC,
private PB_DS_RESIZE_TRAITS_C_DEC,
private PB_DS_NODE_UPDATOR_TRAITS_C_DEC,
private PB_DS_SET_LOADS_TRAITS_C_DEC,
private PB_DS_SET_LOAD_TRAITS_C_DEC
{
private:
typedef PB_DS_NATIVE_TYPE_TRAITS_C_DEC native_type_traits_base;
namespace detail
{
typedef PB_DS_TYPE_TRAITS_C_DEC type_traits_base;
#define PB_DS_CLASS_T_DEC \
template<typename Cntnr>
public:
typedef typename Cntnr::key_type key_type;
#define PB_DS_CLASS_C_DEC \
regression_test_traits< \
Cntnr>
typedef typename Cntnr::const_key_reference const_key_reference;
#define PB_DS_TYPE_TRAITS_C_DEC \
regression_test_type_traits< \
Cntnr>
typedef typename Cntnr::value_type value_type;
#define PB_DS_NATIVE_TYPE_TRAITS_C_DEC \
native_type_traits< \
typename PB_DS_TYPE_TRAITS_C_DEC::key_type, \
typename PB_DS_TYPE_TRAITS_C_DEC::mapped_type, \
typename Cntnr::allocator>
typedef typename Cntnr::const_reference const_reference;
#define PB_DS_RESIZE_TRAITS_C_DEC \
regression_test_resize_traits< \
Cntnr, \
typename Cntnr::container_category>
typedef typename PB_DS_NATIVE_TYPE_TRAITS_C_DEC::type native_type;
#define PB_DS_SET_LOADS_TRAITS_C_DEC \
regression_test_get_set_loacontainer_traits< \
Cntnr, \
typename Cntnr::container_category>
typedef typename native_type::key_type native_key_type;
#define PB_DS_SET_LOAD_TRAITS_C_DEC \
regression_test_get_set_load_traits< \
Cntnr, \
typename Cntnr::container_category>
typedef typename native_type::value_type native_value_type;
#define PB_DS_NODE_UPDATOR_TRAITS_C_DEC \
regression_test_node_update_traits< \
Cntnr, \
typename Cntnr::container_category>
template<typename Cntnr>
struct regression_test_traits : private PB_DS_TYPE_TRAITS_C_DEC,
private PB_DS_NATIVE_TYPE_TRAITS_C_DEC,
private PB_DS_RESIZE_TRAITS_C_DEC,
private PB_DS_NODE_UPDATOR_TRAITS_C_DEC,
private PB_DS_SET_LOADS_TRAITS_C_DEC,
private PB_DS_SET_LOAD_TRAITS_C_DEC
enum
{
private:
typedef PB_DS_NATIVE_TYPE_TRAITS_C_DEC native_type_traits_base;
typedef PB_DS_TYPE_TRAITS_C_DEC type_traits_base;
public:
typedef typename Cntnr::key_type key_type;
typedef typename Cntnr::const_key_reference const_key_reference;
typedef typename Cntnr::value_type value_type;
typedef typename Cntnr::const_reference const_reference;
typedef typename PB_DS_NATIVE_TYPE_TRAITS_C_DEC::type native_type;
typedef typename native_type::key_type native_key_type;
typedef typename native_type::value_type native_value_type;
enum
{
resize = PB_DS_RESIZE_TRAITS_C_DEC::value,
get_set_loads = PB_DS_SET_LOADS_TRAITS_C_DEC::value,
get_set_load = PB_DS_SET_LOAD_TRAITS_C_DEC::value,
order_statistics =
PB_DS_NODE_UPDATOR_TRAITS_C_DEC::order_statistics,
prefix_search =
PB_DS_NODE_UPDATOR_TRAITS_C_DEC::prefix_search
};
template<typename T>
struct erase_if_fn : public regression_test_erase_if_fn<
T>
{
};
static size_t
erase_if(native_type& r_native_c)
{
typedef
regression_test_erase_if_fn<
typename native_type::value_type>
erase_if_fn;
typename native_type::iterator it = r_native_c.begin();
size_t num_ersd = 0;
while (it != r_native_c.end())
if (erase_if_fn()(*it))
{
++num_ersd;
r_native_c.erase(it);
it = r_native_c.begin();
}
else
++it;
return (num_ersd);
}
static void
print_container(const Cntnr& r_c, std::ostream& r_os)
{
PB_DS_TYPE_TRAITS_C_DEC::print_container(r_c, r_os);
}
public:
template<typename Gen>
static key_type
generate_key(Gen& r_gen, size_t max)
{
return (PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max));
}
template<typename Gen>
static value_type
generate_value(Gen& r_gen, size_t max)
{
return (PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max));
}
static const_key_reference
extract_key(const_reference r_val)
{
return type_traits_base::extract_key(r_val);
}
static native_key_type
native_key(const_key_reference r_key)
{
return (native_type_traits_base::native_key(r_key));
}
static native_value_type
native_value(const_reference r_val)
{
return (native_type_traits_base::native_value(r_val));
}
static const native_key_type&
extract_native_key(const native_value_type& r_val)
{
return (native_type_traits_base::extract_key(r_val));
}
static bool
cmp(const_reference r_val, const native_value_type& r_native_val)
{
return (val_to_string(r_val) ==
native_val_to_string(r_native_val));
}
static std::string
val_to_string(const_reference r_val)
{
return (to_string(r_val));
}
static std::string
key_to_string(const_key_reference r_key)
{
return (to_string(r_key));
}
static std::string
native_val_to_string(const native_value_type& r_native_val)
{
return (to_string(r_native_val));
}
static bool
prefix_match(const_key_reference r_key, const std::string& r_native_key)
{
const size_t native_substr_len = std::min(
r_key.length(),
r_native_key.length());
const std::string native_substr =
r_native_key.substr(0, native_substr_len);
return (native_substr == (const std::string& )r_key);
}
resize = PB_DS_RESIZE_TRAITS_C_DEC::value,
get_set_loads = PB_DS_SET_LOADS_TRAITS_C_DEC::value,
get_set_load = PB_DS_SET_LOAD_TRAITS_C_DEC::value,
order_statistics = PB_DS_NODE_UPDATOR_TRAITS_C_DEC::order_statistics,
prefix_search = PB_DS_NODE_UPDATOR_TRAITS_C_DEC::prefix_search
};
template<typename T>
struct erase_if_fn : public regression_test_erase_if_fn<T>
{ };
static size_t
erase_if(native_type& r_native_c)
{
typedef regression_test_erase_if_fn<typename native_type::value_type> erase_if_fn;
typename native_type::iterator it = r_native_c.begin();
size_t num_ersd = 0;
while (it != r_native_c.end())
if (erase_if_fn()(*it))
{
++num_ersd;
r_native_c.erase(it);
it = r_native_c.begin();
}
else
++it;
return num_ersd;
}
static void
print_container(const Cntnr& r_c, std::ostream& r_os)
{
PB_DS_TYPE_TRAITS_C_DEC::print_container(r_c, r_os);
}
public:
template<typename Gen>
static key_type
generate_key(Gen& r_gen, size_t max)
{
return PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max);
}
template<typename Gen>
static value_type
generate_value(Gen& r_gen, size_t max)
{
return PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max);
}
static const_key_reference
extract_key(const_reference r_val)
{
return type_traits_base::extract_key(r_val);
}
static native_key_type
native_key(const_key_reference r_key)
{
return native_type_traits_base::native_key(r_key);
}
static native_value_type
native_value(const_reference r_val)
{
return native_type_traits_base::native_value(r_val);
}
static const native_key_type&
extract_native_key(const native_value_type& r_val)
{
return native_type_traits_base::extract_key(r_val);
}
static bool
cmp(const_reference r_val, const native_value_type& r_native_val)
{
return val_to_string(r_val) == native_val_to_string(r_native_val);
}
static std::string
val_to_string(const_reference r_val)
{
return to_string(r_val);
}
static std::string
key_to_string(const_key_reference r_key)
{
return to_string(r_key);
}
static std::string
native_val_to_string(const native_value_type& r_native_val)
{
return to_string(r_native_val);
}
static bool
prefix_match(const_key_reference r_key, const std::string& r_native_key)
{
const size_t native_substr_len = std::min(r_key.length(),
r_native_key.length());
const std::string native_substr = r_native_key.substr(0,
native_substr_len);
return native_substr == (const std::string&) r_key;
}
};
#undef PB_DS_TYPE_TRAITS_C_DEC
#undef PB_DS_NATIVE_TYPE_TRAITS_C_DEC
#undef PB_DS_RESIZE_TRAITS_C_DEC
#undef PB_DS_SET_LOADS_TRAITS_C_DEC
#undef PB_DS_SET_LOAD_TRAITS_C_DEC
#undef PB_DS_NODE_UPDATOR_TRAITS_C_DEC
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace detail
} // namespace test
} // namespace detail
} // namespace test
} // namespace pb_ds
#endif // #ifndef PB_DS_REGRESSION_TEST_TRAIT_HPP
#endif