From 55a4c999b5e0ad5da3838a157246867c29579e63 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Thu, 6 Jul 2006 17:45:13 +0000 Subject: [PATCH] trait.hpp: Format. 2006-07-06 Benjamin Kosnik * 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 --- libstdc++-v3/ChangeLog | 14 +- .../util/regression/assoc/common_type.hpp | 247 ++---- .../testsuite/util/regression/basic_type.hpp | 85 +- .../regression/priority_queue/common_type.hpp | 27 +- .../assoc/container_rand_regression_test.hpp | 834 +++++++++--------- .../rand/assoc/rand_regression_test.hpp | 8 +- .../priority_queue/rand_regression_test.hpp | 4 + .../util/regression/trait/assoc/trait.hpp | 368 ++++---- 8 files changed, 707 insertions(+), 880 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f52bad98cbd0..78f64a0e1f21 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,4 +1,16 @@ -2006-07-05 Benjamin Kosnik +2006-07-06 Benjamin Kosnik + + * 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 * include/Makefile.am (pch_output): New. (clean-local): Use it. diff --git a/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp b/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp index bc89bd71789f..fa34568b3ed2 100644 --- a/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp +++ b/libstdc++-v3/testsuite/util/regression/assoc/common_type.hpp @@ -52,210 +52,93 @@ namespace pb_ds { +namespace test +{ + typedef dbg_ex_allocator alloc_type; - namespace test + struct hash { + typedef alloc_type::rebind::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(*it); + return ret; + } + }; - size_t - operator()(const_key_reference r_key) const - { - size_t ret = 0; + typedef pb_ds::string_trie_e_access_traits 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(*it); + template + struct tree_types + { + private: + typedef typename tree_common_types, pb_ds::null_tree_node_update, alloc_type>::regression_tl no_order_statistics_tl_t; - return (ret); - } - }; + typedef typename tree_common_types, 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::type tl_t; - template - 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 + struct trie_types + { + private: + typedef typename trie_common_types::regression_tl no_updates_tl_t; - public: + typedef typename trie_common_types::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::regression_tl prefix_search_tl_t; - typedef no_order_statistics_tl_t min_tl_t; - }; + public: + typedef typename pb_ds::detail::typelist_append::type>::type tl_t; - template - 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 + struct hash_types + { + typedef typename hash_common_types, 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 + struct lu_types + { + typedef typename lu_common_types, alloc_type>::regression_tl tl_t; - typedef no_updates_tl_t min_tl_t; - }; + typedef tl_t min_tl_t; + }; - template - 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::tl_t tree_set_tl_t; + typedef tree_types::min_tl_t min_tree_set_tl_t; + typedef tree_types::tl_t tree_map_tl_t; + typedef tree_types::min_tl_t min_tree_map_tl_t; - typedef tl_t min_tl_t; - }; + typedef hash_types::tl_t hash_set_tl_t; + typedef hash_types::min_tl_t min_hash_set_tl_t; + typedef hash_types::tl_t hash_map_tl_t; + typedef hash_types::min_tl_t min_hash_map_tl_t; - template - 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::tl_t lu_set_tl_t; + typedef lu_types::min_tl_t min_lu_set_tl_t; + typedef lu_types::tl_t lu_map_tl_t; + typedef lu_types::min_tl_t min_lu_map_tl_t; + typedef trie_types::tl_t trie_set_tl_t; + typedef trie_types::min_tl_t min_trie_set_tl_t; + typedef trie_types::tl_t trie_map_tl_t; + typedef trie_types::min_tl_t min_trie_map_tl_t; +} // namespace test } // namespace pb_ds #endif // #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP diff --git a/libstdc++-v3/testsuite/util/regression/basic_type.hpp b/libstdc++-v3/testsuite/util/regression/basic_type.hpp index 60e970bd471c..626f9e6f3a50 100644 --- a/libstdc++-v3/testsuite/util/regression/basic_type.hpp +++ b/libstdc++-v3/testsuite/util/regression/basic_type.hpp @@ -52,67 +52,52 @@ namespace pb_ds { +namespace test +{ +#define PB_DS_BASE_C_DEC \ + std::basic_string, dbg_ex_allocator > - 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 + basic_type(Gen& r_gen, size_t max) { - public: - enum + size_t rnd = r_gen.get_unsigned_long(0, static_cast(max)); + while (rnd > 0) { - distinct_chars = 4 - }; + base_type::push_back('a' + static_cast(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 - basic_type(Gen& r_gen, size_t max) - { - size_t rnd = - r_gen.get_unsigned_long(0, static_cast(max)); - - while (rnd > 0) - { - PB_DS_BASE_C_DEC::push_back('a' + - static_cast(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 diff --git a/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp b/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp index 4c67167a0e23..c8e6b3d92e9a 100644 --- a/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp +++ b/libstdc++-v3/testsuite/util/regression/priority_queue/common_type.hpp @@ -52,27 +52,14 @@ namespace pb_ds { +namespace test +{ + typedef dbg_ex_allocator 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, 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 diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp index 4f4c144b8d2a..440c349cad9c 100644 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp +++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.hpp @@ -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 +#define PB_DS_CLASS_T_DEC \ + template -#define PB_DS_CLASS_C_DEC \ - container_rand_regression_test< \ - Cntnr> +#define PB_DS_CLASS_C_DEC \ + container_rand_regression_test -#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 - class container_rand_regression_test + // Rand test specialized for a specific container. + template + 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 test_traits; + + typedef pb_ds::container_traits 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 - void - it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, Const_Native_It native_e); - - template - 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 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 + void + it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It); + + template + 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 #include #include @@ -504,27 +504,17 @@ namespace pb_ds #include #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 diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp index 2a169434977b..a7c3b7b8b305 100644 --- a/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp +++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp @@ -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 #include #include @@ -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 diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp index ebd6d33c8d25..385a2c4dda26 100644 --- a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp +++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp @@ -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 #include #include @@ -208,3 +211,4 @@ namespace detail } // namespace test } // namespace pb_ds +#endif diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp index 8cf8c1271fcb..65a63630f6f7 100644 --- a/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp +++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp @@ -59,231 +59,193 @@ namespace pb_ds { +namespace test +{ +namespace detail +{ - namespace test +#define PB_DS_CLASS_T_DEC \ + template + +#define PB_DS_CLASS_C_DEC \ + regression_test_traits + +#define PB_DS_TYPE_TRAITS_C_DEC \ + regression_test_type_traits + +#define PB_DS_NATIVE_TYPE_TRAITS_C_DEC \ + native_type_traits + +#define PB_DS_RESIZE_TRAITS_C_DEC \ + regression_test_resize_traits + +#define PB_DS_SET_LOADS_TRAITS_C_DEC \ + regression_test_get_set_loacontainer_traits + +#define PB_DS_SET_LOAD_TRAITS_C_DEC \ + regression_test_get_set_load_traits + +#define PB_DS_NODE_UPDATOR_TRAITS_C_DEC \ + regression_test_node_update_traits + + template + 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 + 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 - 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 - 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 - static key_type - generate_key(Gen& r_gen, size_t max) - { - return (PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max)); - } - - template - 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 + struct erase_if_fn : public regression_test_erase_if_fn + { }; + + static size_t + erase_if(native_type& r_native_c) + { + typedef regression_test_erase_if_fn 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 + static key_type + generate_key(Gen& r_gen, size_t max) + { + return PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max); + } + + template + 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