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(); \
- }
-
-#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!"); \
- }
+ 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) \
- PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__)
-
-#define PB_DS_SET_DESTRUCT_PRINT \
- destructor_printer dest_print___(__FUNCTION__);
+ PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__)
-#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
- {
+#define PB_DS_SET_DESTRUCT_PRINT \
+ destructor_printer dest_print___(__FUNCTION__);
- public:
+#define PB_DS_CANCEL_DESTRUCT_PRINT \
+ dest_print___.cancel_print();
- 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);
+ // Rand test specialized for a specific container.
+ template<typename Cntnr>
+ class container_rand_regression_test
+ {
+ public:
- virtual
- ~container_rand_regression_test();
+ container_rand_regression_test(unsigned long, size_t, size_t, double,
+ double, double, double, double, bool);
- void
- operator()();
+ virtual
+ ~container_rand_regression_test();
- private:
- typedef Cntnr cntnr;
+ void
+ operator()();
- typedef typename cntnr::allocator allocator;
+ private:
+ typedef Cntnr cntnr;
- typedef typename cntnr::size_type size_type;
+ typedef typename cntnr::allocator allocator;
- typedef twister_rand_gen gen;
+ typedef typename cntnr::size_type size_type;
- typedef regression_test_traits< Cntnr> test_traits;
+ typedef twister_rand_gen gen;
- typedef pb_ds::container_traits< Cntnr> container_traits;
+ typedef regression_test_traits<Cntnr> test_traits;
- typedef typename test_traits::key_type key_type;
+ typedef pb_ds::container_traits<Cntnr> container_traits;
- typedef typename test_traits::const_key_reference const_key_reference;
+ typedef typename test_traits::key_type key_type;
- typedef typename test_traits::value_type value_type;
+ typedef typename test_traits::const_key_reference const_key_reference;
- typedef typename test_traits::native_type native_type;
+ typedef typename test_traits::value_type value_type;
- enum op
- {
- insert_op,
- erase_op,
- clear_op,
- other_op
- };
+ typedef typename test_traits::native_type native_type;
- typedef dbg_ex_allocator< char> alloc_t;
+ enum op
+ {
+ insert_op,
+ erase_op,
+ clear_op,
+ other_op
+ };
- private:
+ typedef dbg_ex_allocator<char> alloc_t;
- op
- get_next_op();
+ private:
- size_t
- get_next_sub_op(size_t max);
+ op
+ get_next_op();
- static void
- defs();
+ size_t
+ get_next_sub_op(size_t);
- static void
- key_defs();
+ static void
+ defs();
- static void
- mapped_defs();
+ static void
+ key_defs();
- static void
- value_defs();
+ static void
+ mapped_defs();
- static void
- ds_defs();
+ static void
+ value_defs();
- static void
- iterator_defs();
+ static void
+ ds_defs();
- static void
- node_iterator_defs(pb_ds::detail::false_type);
+ static void
+ iterator_defs();
- static void
- node_iterator_defs(pb_ds::detail::true_type);
+ static void
+ node_iterator_defs(pb_ds::detail::false_type);
- static void
- policy_defs();
+ static void
+ node_iterator_defs(pb_ds::detail::true_type);
- static void
- policy_defs(pb_ds::basic_hash_tag);
+ static void
+ policy_defs();
- static void
- policy_defs(pb_ds::cc_hash_tag);
+ static void
+ policy_defs(pb_ds::basic_hash_tag);
- static void
- policy_defs(pb_ds::gp_hash_tag);
+ static void
+ policy_defs(pb_ds::cc_hash_tag);
- static void
- policy_defs(pb_ds::tree_tag);
+ static void
+ policy_defs(pb_ds::gp_hash_tag);
- static void
- policy_defs(pb_ds::list_update_tag);
+ static void
+ policy_defs(pb_ds::tree_tag);
- static void
- policy_defs(pb_ds::pat_trie_tag);
+ static void
+ policy_defs(pb_ds::list_update_tag);
- void
- policy_access();
+ static void
+ policy_defs(pb_ds::pat_trie_tag);
- void
- policy_access(pb_ds::basic_hash_tag);
+ void
+ policy_access();
- void
- policy_access(pb_ds::cc_hash_tag);
+ void
+ policy_access(pb_ds::basic_hash_tag);
- void
- policy_access(pb_ds::gp_hash_tag);
+ void
+ policy_access(pb_ds::cc_hash_tag);
- void
- policy_access(pb_ds::tree_tag);
+ void
+ policy_access(pb_ds::gp_hash_tag);
- void
- policy_access(pb_ds::list_update_tag);
+ void
+ policy_access(pb_ds::tree_tag);
- void
- policy_access(pb_ds::pat_trie_tag);
+ void
+ policy_access(pb_ds::list_update_tag);
- void
- it_copy();
+ void
+ policy_access(pb_ds::pat_trie_tag);
- void
- it_assign();
+ void
+ it_copy();
- void
- rev_it_copy();
+ void
+ it_assign();
- void
- rev_it_assign();
+ void
+ rev_it_copy();
- void
- rev_it_copy_imp(pb_ds::detail::false_type);
+ void
+ rev_it_assign();
- void
- rev_it_copy_imp(pb_ds::detail::true_type);
+ void
+ rev_it_copy_imp(pb_ds::detail::false_type);
- void
- rev_it_assign_imp(pb_ds::detail::false_type);
+ void
+ rev_it_copy_imp(pb_ds::detail::true_type);
- void
- rev_it_assign_imp(pb_ds::detail::true_type);
+ void
+ rev_it_assign_imp(pb_ds::detail::false_type);
- bool
- default_constructor();
+ void
+ rev_it_assign_imp(pb_ds::detail::true_type);
- void
- swap();
+ bool
+ default_constructor();
- bool
- copy_constructor();
+ void
+ swap();
- bool
- assignment_operator();
+ bool
+ copy_constructor();
- bool
- it_constructor();
+ bool
+ assignment_operator();
- bool
- it_constructor_imp(pb_ds::cc_hash_tag);
+ bool
+ it_constructor();
- bool
- it_constructor_imp(pb_ds::gp_hash_tag);
+ bool
+ it_constructor_imp(pb_ds::cc_hash_tag);
- bool
- it_constructor_imp(pb_ds::tree_tag);
+ bool
+ it_constructor_imp(pb_ds::gp_hash_tag);
- bool
- it_constructor_imp(pb_ds::list_update_tag);
+ bool
+ it_constructor_imp(pb_ds::tree_tag);
- bool
- it_constructor_imp(pb_ds::pat_trie_tag);
+ bool
+ it_constructor_imp(pb_ds::list_update_tag);
- bool
- insert();
+ bool
+ it_constructor_imp(pb_ds::pat_trie_tag);
- bool
- erase();
+ bool
+ insert();
- bool
- erase_it();
+ bool
+ erase();
- bool
- erase_it_imp(pb_ds::detail::false_type);
+ bool
+ erase_it();
- bool
- erase_it_imp(pb_ds::detail::true_type);
+ bool
+ erase_it_imp(pb_ds::detail::false_type);
- bool
- erase_rev_it();
+ bool
+ erase_it_imp(pb_ds::detail::true_type);
- bool
- erase_rev_it_imp(pb_ds::detail::false_type);
+ bool
+ erase_rev_it();
- bool
- erase_rev_it_imp(pb_ds::detail::true_type);
+ bool
+ erase_rev_it_imp(pb_ds::detail::false_type);
- bool
- erase_if();
+ bool
+ erase_rev_it_imp(pb_ds::detail::true_type);
- bool
- clear();
+ bool
+ erase_if();
- bool
- resize();
+ bool
+ clear();
- bool
- resize_imp(pb_ds::detail::true_type);
+ bool
+ resize();
- bool
- resize_imp(pb_ds::detail::false_type);
+ bool
+ resize_imp(pb_ds::detail::true_type);
- bool
- get_set_loads();
+ bool
+ resize_imp(pb_ds::detail::false_type);
- bool
- get_set_loads_imp(pb_ds::detail::true_type);
+ bool
+ get_set_loads();
- bool
- get_set_loads_imp(pb_ds::detail::false_type);
+ bool
+ get_set_loads_imp(pb_ds::detail::true_type);
- void
- get_set_load();
+ bool
+ get_set_loads_imp(pb_ds::detail::false_type);
- void
- get_set_load_imp(pb_ds::detail::true_type);
+ void
+ get_set_load();
- void
- get_set_load_imp(pb_ds::detail::false_type);
+ void
+ get_set_load_imp(pb_ds::detail::true_type);
- bool
- subscript();
+ void
+ get_set_load_imp(pb_ds::detail::false_type);
- bool
- subscript_imp(pb_ds::detail::false_type);
+ bool
+ subscript();
- bool
- subscript_imp(pb_ds::detail::true_type);
+ bool
+ subscript_imp(pb_ds::detail::false_type);
- bool
- split_join();
+ bool
+ subscript_imp(pb_ds::detail::true_type);
- bool
- split_join_imp(pb_ds::detail::false_type);
+ bool
+ split_join();
- bool
- split_join_imp(pb_ds::detail::true_type);
+ bool
+ split_join_imp(pb_ds::detail::false_type);
- void
- cmp(const Cntnr& r_container, const native_type& r_native_c, const std::string& r_call_fn);
+ bool
+ split_join_imp(pb_ds::detail::true_type);
- void
- basic_cmp_(const Cntnr& r_container, const native_type& r_native_c);
+ void
+ cmp(const Cntnr&, const native_type&, const std::string&);
- void
- cmp_(const Cntnr& r_container, const native_type& r_native_c);
+ void
+ basic_cmp_(const Cntnr&, const native_type&);
- void
- order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
+ void
+ cmp_(const Cntnr&, const native_type&);
- void
- order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
+ void
+ order_preserving_cmp_imp(const Cntnr&, const native_type&,
+ pb_ds::detail::false_type);
- void
- back_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&, const native_type&,
+ pb_ds::detail::true_type);
- void
- back_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&, const native_type&,
+ pb_ds::detail::false_type);
- void
- reverse_iteration_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&, const native_type&,
+ pb_ds::detail::true_type);
- void
- reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
+ void
+ reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
+ pb_ds::detail::false_type);
- void
- order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, 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& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
+ void
+ order_statistics_cmp_imp(const Cntnr&, const native_type&,
+ pb_ds::detail::false_type);
- void
- prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, 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& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
+ void
+ prefix_search_cmp_imp(const Cntnr&, const native_type&,
+ pb_ds::detail::false_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);
+ void
+ prefix_search_cmp_imp(const Cntnr&, const native_type&,
+ pb_ds::detail::true_type);
- 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);
+ template<typename Const_It, class Const_Native_It>
+ void
+ it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It);
- void
- lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type);
+ 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& r_c, const native_type& r_native_c, pb_ds::detail::true_type);
+ void
+ lower_bound_cmp_imp(const Cntnr&, const native_type&,
+ pb_ds::detail::false_type);
- void
- upper_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&, const native_type&,
+ pb_ds::detail::true_type);
- void
- upper_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&, const native_type&,
+ pb_ds::detail::false_type);
- void
- print_container(const native_type& r_cnt, std::ostream& r_os = std::cerr) const;
+ void
+ upper_bound_cmp_imp(const Cntnr&, const native_type&,
+ pb_ds::detail::true_type);
- void
- print_container(const cntnr& r_cnt, std::ostream& r_os = std::cerr) const;
+ void
+ print_container(const native_type&, 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
+ print_container(const cntnr&, std::ostream& r_os = std::cerr) const;
- void
- cancel_print()
- {
- m_print = false;
- }
+ private:
+ struct destructor_printer
+ {
+ destructor_printer(const std::string& r_msg)
+ : m_msg(r_msg), m_print(true) { }
- ~destructor_printer()
- {
- if (!m_print)
- return;
+ void
+ cancel_print()
+ { m_print = false; }
- std::cerr << std::endl <<
- "Uncaught exception: " << std::endl <<
- m_msg << std::endl;
- }
+ ~destructor_printer()
+ {
+ if (!m_print)
+ return;
- private:
- const std::string m_msg;
+ std::cerr << std::endl << "Uncaught exception: " << std::endl
+ << m_msg << std::endl;
+ }
- bool m_print;
- };
+ private:
+ const std::string m_msg;
+ bool m_print;
+ };
- private:
- const unsigned long m_seed;
+ 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;
+ 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;
+ twister_rand_gen m_g;
- Cntnr* m_p_c;
+ Cntnr* m_p_c;
- native_type m_native_c;
+ native_type m_native_c;
- alloc_t m_alloc;
+ alloc_t m_alloc;
- size_t m_i;
- };
+ 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/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