Commit 55a4c999 by Benjamin Kosnik Committed by Benjamin Kosnik

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
parent cec12c7a
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> 2006-07-05 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (pch_output): New. * include/Makefile.am (pch_output): New.
......
...@@ -52,74 +52,37 @@ ...@@ -52,74 +52,37 @@
namespace pb_ds namespace pb_ds
{ {
namespace test
namespace test {
{ typedef dbg_ex_allocator<basic_type> alloc_type;
typedef
pb_ds::test::dbg_ex_allocator<
pb_ds::test::basic_type>
alloc_type;
struct hash struct hash
{ {
typedef typedef alloc_type::rebind<basic_type>::other::const_reference const_key_reference;
alloc_type::rebind<
pb_ds::test::basic_type>::other::const_reference
const_key_reference;
size_t size_t
operator()(const_key_reference r_key) const operator()(const_key_reference r_key) const
{ {
size_t ret = 0; size_t ret = 0;
typedef basic_type::const_iterator const_iterator;
for (pb_ds::test::basic_type::const_iterator it = r_key.begin(); it != r_key.end(); ++it) for (const_iterator it = r_key.begin(); it != r_key.end(); ++it)
ret = ret* 5 + static_cast<size_t>(*it); ret = ret * 5 + static_cast<size_t>(*it);
return ret;
return (ret);
} }
}; };
typedef typedef pb_ds::string_trie_e_access_traits<basic_type, 'a', 'a' + basic_type::distinct_chars - 1, false, alloc_type> e_access_traits_t;
pb_ds::string_trie_e_access_traits<
basic_type,
'a',
'a' + basic_type::distinct_chars - 1,
false,
alloc_type>
e_access_traits_t;
template<typename Data_Type> template<typename Data_Type>
struct tree_types struct tree_types
{ {
private: private:
typedef 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;
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 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;
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;
public: public:
typedef typename pb_ds::detail::typelist_append<no_order_statistics_tl_t, order_statistics_tl_t>::type tl_t;
typedef
typename pb_ds::detail::typelist_append<
no_order_statistics_tl_t,
order_statistics_tl_t>::type
tl_t;
typedef no_order_statistics_tl_t min_tl_t; typedef no_order_statistics_tl_t min_tl_t;
}; };
...@@ -128,44 +91,14 @@ namespace pb_ds ...@@ -128,44 +91,14 @@ namespace pb_ds
struct trie_types struct trie_types
{ {
private: private:
typedef 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;
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 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;
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;
typedef 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;
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;
public: public:
typedef 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;
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;
typedef no_updates_tl_t min_tl_t; typedef no_updates_tl_t min_tl_t;
}; };
...@@ -173,15 +106,7 @@ namespace pb_ds ...@@ -173,15 +106,7 @@ namespace pb_ds
template<typename Data_Type> template<typename Data_Type>
struct hash_types struct hash_types
{ {
typedef typedef typename hash_common_types<basic_type, Data_Type, hash, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t;
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 tl_t min_tl_t; typedef tl_t min_tl_t;
}; };
...@@ -189,73 +114,31 @@ namespace pb_ds ...@@ -189,73 +114,31 @@ namespace pb_ds
template<typename Data_Type> template<typename Data_Type>
struct lu_types struct lu_types
{ {
typedef typedef typename lu_common_types<basic_type, Data_Type, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t;
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 tl_t min_tl_t;
}; };
typedef typedef tree_types<null_mapped_type>::tl_t tree_set_tl_t;
tree_types< typedef tree_types<null_mapped_type>::min_tl_t min_tree_set_tl_t;
pb_ds::null_mapped_type>::tl_t typedef tree_types<basic_type>::tl_t tree_map_tl_t;
tree_set_tl_t; typedef tree_types<basic_type>::min_tl_t min_tree_map_tl_t;
typedef typedef hash_types<null_mapped_type>::tl_t hash_set_tl_t;
tree_types< typedef hash_types<null_mapped_type>::min_tl_t min_hash_set_tl_t;
pb_ds::null_mapped_type>::min_tl_t typedef hash_types<basic_type>::tl_t hash_map_tl_t;
min_tree_set_tl_t; typedef hash_types<basic_type>::min_tl_t min_hash_map_tl_t;
typedef typedef lu_types<null_mapped_type>::tl_t lu_set_tl_t;
hash_types< typedef lu_types<null_mapped_type>::min_tl_t min_lu_set_tl_t;
pb_ds::null_mapped_type>::tl_t typedef lu_types<basic_type>::tl_t lu_map_tl_t;
hash_set_tl_t; typedef lu_types<basic_type>::min_tl_t min_lu_map_tl_t;
typedef typedef trie_types<null_mapped_type>::tl_t trie_set_tl_t;
hash_types< typedef trie_types<null_mapped_type>::min_tl_t min_trie_set_tl_t;
pb_ds::null_mapped_type>::min_tl_t typedef trie_types<basic_type>::tl_t trie_map_tl_t;
min_hash_set_tl_t; typedef trie_types<basic_type>::min_tl_t min_trie_map_tl_t;
} // namespace test
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
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP #endif // #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP
...@@ -52,41 +52,31 @@ ...@@ -52,41 +52,31 @@
namespace pb_ds namespace pb_ds
{ {
namespace test
namespace test {
{
#define PB_DS_BASE_C_DEC \ #define PB_DS_BASE_C_DEC \
std::basic_string< \ std::basic_string<char, std::char_traits<char>, dbg_ex_allocator<char> >
char, \
std::char_traits< \
char>, \
dbg_ex_allocator< \
char> >
struct basic_type : public PB_DS_BASE_C_DEC struct basic_type : public PB_DS_BASE_C_DEC
{ {
private:
typedef PB_DS_BASE_C_DEC base_type;
public: public:
enum enum
{ {
distinct_chars = 4 distinct_chars = 4
}; };
public: basic_type() { }
basic_type()
{ }
template<typename Gen> template<typename Gen>
basic_type(Gen& r_gen, size_t max) basic_type(Gen& r_gen, size_t max)
{ {
size_t rnd = size_t rnd = r_gen.get_unsigned_long(0, static_cast<unsigned long>(max));
r_gen.get_unsigned_long(0, static_cast<unsigned long>(max));
while (rnd > 0) while (rnd > 0)
{ {
PB_DS_BASE_C_DEC::push_back('a' + base_type::push_back('a' + static_cast<char>(rnd % distinct_chars));
static_cast<char>(rnd % distinct_chars));
rnd /= distinct_chars; rnd /= distinct_chars;
} }
} }
...@@ -94,25 +84,20 @@ namespace pb_ds ...@@ -94,25 +84,20 @@ namespace pb_ds
basic_type(const std::string other) basic_type(const std::string other)
{ {
std::string::const_iterator it = other.begin(); std::string::const_iterator it = other.begin();
while (it != other.end()) while (it != other.end())
{ {
PB_DS_BASE_C_DEC::push_back(*it); base_type::push_back(*it);
++it; ++it;
} }
} }
operator std::string() const operator std::string() const
{ { return std::string(base_type::c_str());}
return (std::string(PB_DS_BASE_C_DEC::c_str()));
}
}; };
#undef PB_DS_BASE_C_DEC #undef PB_DS_BASE_C_DEC
} // namespace test } // namespace test
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_BASIC_TYPE_HPP #endif // #ifndef PB_DS_BASIC_TYPE_HPP
...@@ -52,27 +52,14 @@ ...@@ -52,27 +52,14 @@
namespace pb_ds namespace pb_ds
{ {
namespace test
{
typedef dbg_ex_allocator<basic_type> alloc_type;
namespace test typedef pq_common_types<basic_type, std::less<basic_type>, alloc_type>::regression_tl pq_tl_t;
{
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; typedef pq_tl_t min_pq_tl_t;
} // namespace test
} // namespace test
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP #endif
...@@ -60,25 +60,22 @@ ...@@ -60,25 +60,22 @@
namespace pb_ds namespace pb_ds
{ {
namespace test
namespace test {
{ namespace detail
{
namespace detail
{
#ifdef PB_DS_REGRESSION_TRACE #ifdef PB_DS_REGRESSION_TRACE
#define PB_DS_TRACE(X) std::cerr << X << std::endl #define PB_DS_TRACE(X) std::cerr << X << std::endl
#else // #ifdef PB_DS_REGRESSION_TRACE #else
#define PB_DS_TRACE(X) #define PB_DS_TRACE(X)
#endif // #ifdef PB_DS_REGRESSION_TRACE #endif
#define PB_DS_CLASS_T_DEC \ #define PB_DS_CLASS_T_DEC \
template<typename Cntnr> template<typename Cntnr>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
container_rand_regression_test< \ container_rand_regression_test<Cntnr>
Cntnr>
#define PB_DS_COND_COMPARE(L, R) \ #define PB_DS_COND_COMPARE(L, R) \
if (m_g.get_prob() < m_mp) \ if (m_g.get_prob() < m_mp) \
...@@ -96,19 +93,13 @@ namespace pb_ds ...@@ -96,19 +93,13 @@ namespace pb_ds
if (!(PRED)) \ if (!(PRED)) \
{ \ { \
std::cerr << "Failure at " << F << ": " << L << std::endl; \ std::cerr << "Failure at " << F << ": " << L << std::endl; \
\
std::cerr << MORE << std::endl; \ std::cerr << MORE << std::endl; \
\
std::cerr << "container:" << std::endl; \ std::cerr << "container:" << std::endl; \
\
print_container(*(P_C)); \ print_container(*(P_C)); \
std::cerr << std::endl; \ std::cerr << std::endl; \
\
std::cerr << "native container:" << std::endl; \ std::cerr << "native container:" << std::endl; \
\
print_container(*(P_NC)); \ print_container(*(P_NC)); \
std::cerr << std::endl; \ std::cerr << std::endl; \
\
throw std::logic_error("fucked!"); \ throw std::logic_error("fucked!"); \
} }
...@@ -125,10 +116,10 @@ namespace pb_ds ...@@ -125,10 +116,10 @@ namespace pb_ds
template<typename Cntnr> template<typename Cntnr>
class container_rand_regression_test class container_rand_regression_test
{ {
public: 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); container_rand_regression_test(unsigned long, size_t, size_t, double,
double, double, double, double, bool);
virtual virtual
~container_rand_regression_test(); ~container_rand_regression_test();
...@@ -145,9 +136,9 @@ namespace pb_ds ...@@ -145,9 +136,9 @@ namespace pb_ds
typedef twister_rand_gen gen; typedef twister_rand_gen gen;
typedef regression_test_traits< Cntnr> test_traits; typedef regression_test_traits<Cntnr> test_traits;
typedef pb_ds::container_traits< Cntnr> container_traits; typedef pb_ds::container_traits<Cntnr> container_traits;
typedef typename test_traits::key_type key_type; typedef typename test_traits::key_type key_type;
...@@ -165,7 +156,7 @@ namespace pb_ds ...@@ -165,7 +156,7 @@ namespace pb_ds
other_op other_op
}; };
typedef dbg_ex_allocator< char> alloc_t; typedef dbg_ex_allocator<char> alloc_t;
private: private:
...@@ -173,7 +164,7 @@ namespace pb_ds ...@@ -173,7 +164,7 @@ namespace pb_ds
get_next_op(); get_next_op();
size_t size_t
get_next_sub_op(size_t max); get_next_sub_op(size_t);
static void static void
defs(); defs();
...@@ -371,96 +362,105 @@ namespace pb_ds ...@@ -371,96 +362,105 @@ namespace pb_ds
split_join_imp(pb_ds::detail::true_type); split_join_imp(pb_ds::detail::true_type);
void void
cmp(const Cntnr& r_container, const native_type& r_native_c, const std::string& r_call_fn); cmp(const Cntnr&, const native_type&, const std::string&);
void void
basic_cmp_(const Cntnr& r_container, const native_type& r_native_c); basic_cmp_(const Cntnr&, const native_type&);
void void
cmp_(const Cntnr& r_container, const native_type& r_native_c); cmp_(const Cntnr&, const native_type&);
void void
order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type); order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void void
order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type); order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void void
back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type); back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void void
back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type); back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void void
reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type); reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void void
reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type); reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void void
order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type); order_statistics_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void void
order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type); order_statistics_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void void
prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type); prefix_search_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void void
prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type); prefix_search_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
template<typename Const_It, class Const_Native_It> template<typename Const_It, class Const_Native_It>
void void
it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, Const_Native_It native_e); it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It);
template<typename Const_It, class Const_Native_It> template<typename Const_It, class Const_Native_It>
void void
back_it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b, Const_Native_It native_e); back_it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It);
void void
lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type); lower_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void void
lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type); lower_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void void
upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::false_type); upper_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::false_type);
void void
upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, pb_ds::detail::true_type); upper_bound_cmp_imp(const Cntnr&, const native_type&,
pb_ds::detail::true_type);
void void
print_container(const native_type& r_cnt, std::ostream& r_os = std::cerr) const; print_container(const native_type&, std::ostream& r_os = std::cerr) const;
void void
print_container(const cntnr& r_cnt, std::ostream& r_os = std::cerr) const; print_container(const cntnr&, std::ostream& r_os = std::cerr) const;
private: private:
struct destructor_printer struct destructor_printer
{ {
destructor_printer(const std::string& r_msg) : m_msg(r_msg), destructor_printer(const std::string& r_msg)
m_print(true) : m_msg(r_msg), m_print(true) { }
{ }
void void
cancel_print() cancel_print()
{ { m_print = false; }
m_print = false;
}
~destructor_printer() ~destructor_printer()
{ {
if (!m_print) if (!m_print)
return; return;
std::cerr << std::endl << std::cerr << std::endl << "Uncaught exception: " << std::endl
"Uncaught exception: " << std::endl << << m_msg << std::endl;
m_msg << std::endl;
} }
private: private:
const std::string m_msg; const std::string m_msg;
bool m_print; bool m_print;
}; };
...@@ -504,27 +504,17 @@ namespace pb_ds ...@@ -504,27 +504,17 @@ namespace pb_ds
#include <regression/rand/assoc/detail/diagnostic_fn_imps.hpp> #include <regression/rand/assoc/detail/diagnostic_fn_imps.hpp>
#undef PB_DS_COND_COMPARE #undef PB_DS_COND_COMPARE
#undef PB_DS_RUN_MTHD #undef PB_DS_RUN_MTHD
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
#undef PB_DS_THROW_IF_FAILED_ #undef PB_DS_THROW_IF_FAILED_
#undef PB_DS_THROW_IF_FAILED #undef PB_DS_THROW_IF_FAILED
#undef PB_DS_SET_DESTRUCT_PRINT #undef PB_DS_SET_DESTRUCT_PRINT
#undef PB_DS_CANCEL_DESTRUCT_PRINT #undef PB_DS_CANCEL_DESTRUCT_PRINT
#undef PB_DS_TRACE #undef PB_DS_TRACE
} // namespace detail } // namespace detail
} // namespace test
} // namespace test
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_HPP #endif
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
* Contains a random-operation test. * Contains a random-operation test.
*/ */
#ifndef PB_DS_ASSOC_RAND_REGRESSION_TEST_HPP
#define PB_DS_ASSOC_RAND_REGRESSION_TEST_HPP
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <regression/rand/assoc/container_rand_regression_test.hpp> #include <regression/rand/assoc/container_rand_regression_test.hpp>
...@@ -120,12 +123,12 @@ namespace detail ...@@ -120,12 +123,12 @@ namespace detail
{ {
detail::verify_params(sd, n, m, tp, ip, ep, cp, mp, disp); 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); detail::usage(name);
return -1; return -1;
} }
catch(...) catch (...)
{ {
return -2; return -2;
}; };
...@@ -204,3 +207,4 @@ namespace detail ...@@ -204,3 +207,4 @@ namespace detail
} // namespace test } // namespace test
} // namespace pb_ds } // namespace pb_ds
#endif
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
* Contains a random-operation test. * Contains a random-operation test.
*/ */
#ifndef PB_DS_PQ_RAND_REGRESSION_TEST_HPP
#define PB_DS_PQ_RAND_REGRESSION_TEST_HPP
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <regression/rand/priority_queue/container_rand_regression_test.hpp> #include <regression/rand/priority_queue/container_rand_regression_test.hpp>
...@@ -208,3 +211,4 @@ namespace detail ...@@ -208,3 +211,4 @@ namespace detail
} // namespace test } // namespace test
} // namespace pb_ds } // namespace pb_ds
#endif
...@@ -59,49 +59,37 @@ ...@@ -59,49 +59,37 @@
namespace pb_ds namespace pb_ds
{ {
namespace test
namespace test {
{ namespace detail
{
namespace detail
{
#define PB_DS_CLASS_T_DEC \ #define PB_DS_CLASS_T_DEC \
template<typename Cntnr> template<typename Cntnr>
#define PB_DS_CLASS_C_DEC \ #define PB_DS_CLASS_C_DEC \
regression_test_traits< \ regression_test_traits<Cntnr>
Cntnr>
#define PB_DS_TYPE_TRAITS_C_DEC \ #define PB_DS_TYPE_TRAITS_C_DEC \
regression_test_type_traits< \ regression_test_type_traits<Cntnr>
Cntnr>
#define PB_DS_NATIVE_TYPE_TRAITS_C_DEC \ #define PB_DS_NATIVE_TYPE_TRAITS_C_DEC \
native_type_traits< \ native_type_traits<typename PB_DS_TYPE_TRAITS_C_DEC::key_type, \
typename PB_DS_TYPE_TRAITS_C_DEC::key_type, \
typename PB_DS_TYPE_TRAITS_C_DEC::mapped_type, \ typename PB_DS_TYPE_TRAITS_C_DEC::mapped_type, \
typename Cntnr::allocator> typename Cntnr::allocator>
#define PB_DS_RESIZE_TRAITS_C_DEC \ #define PB_DS_RESIZE_TRAITS_C_DEC \
regression_test_resize_traits< \ regression_test_resize_traits<Cntnr, typename Cntnr::container_category>
Cntnr, \
typename Cntnr::container_category>
#define PB_DS_SET_LOADS_TRAITS_C_DEC \ #define PB_DS_SET_LOADS_TRAITS_C_DEC \
regression_test_get_set_loacontainer_traits< \ regression_test_get_set_loacontainer_traits<Cntnr, \
Cntnr, \
typename Cntnr::container_category> typename Cntnr::container_category>
#define PB_DS_SET_LOAD_TRAITS_C_DEC \ #define PB_DS_SET_LOAD_TRAITS_C_DEC \
regression_test_get_set_load_traits< \ regression_test_get_set_load_traits<Cntnr,typename Cntnr::container_category>
Cntnr, \
typename Cntnr::container_category>
#define PB_DS_NODE_UPDATOR_TRAITS_C_DEC \ #define PB_DS_NODE_UPDATOR_TRAITS_C_DEC \
regression_test_node_update_traits< \ regression_test_node_update_traits<Cntnr, typename Cntnr::container_category>
Cntnr, \
typename Cntnr::container_category>
template<typename Cntnr> template<typename Cntnr>
struct regression_test_traits : private PB_DS_TYPE_TRAITS_C_DEC, struct regression_test_traits : private PB_DS_TYPE_TRAITS_C_DEC,
...@@ -111,14 +99,12 @@ namespace pb_ds ...@@ -111,14 +99,12 @@ namespace pb_ds
private PB_DS_SET_LOADS_TRAITS_C_DEC, private PB_DS_SET_LOADS_TRAITS_C_DEC,
private PB_DS_SET_LOAD_TRAITS_C_DEC private PB_DS_SET_LOAD_TRAITS_C_DEC
{ {
private: private:
typedef PB_DS_NATIVE_TYPE_TRAITS_C_DEC native_type_traits_base; typedef PB_DS_NATIVE_TYPE_TRAITS_C_DEC native_type_traits_base;
typedef PB_DS_TYPE_TRAITS_C_DEC type_traits_base; typedef PB_DS_TYPE_TRAITS_C_DEC type_traits_base;
public: public:
typedef typename Cntnr::key_type key_type; typedef typename Cntnr::key_type key_type;
typedef typename Cntnr::const_key_reference const_key_reference; typedef typename Cntnr::const_key_reference const_key_reference;
...@@ -138,44 +124,31 @@ namespace pb_ds ...@@ -138,44 +124,31 @@ namespace pb_ds
resize = PB_DS_RESIZE_TRAITS_C_DEC::value, resize = PB_DS_RESIZE_TRAITS_C_DEC::value,
get_set_loads = PB_DS_SET_LOADS_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, get_set_load = PB_DS_SET_LOAD_TRAITS_C_DEC::value,
order_statistics = order_statistics = PB_DS_NODE_UPDATOR_TRAITS_C_DEC::order_statistics,
PB_DS_NODE_UPDATOR_TRAITS_C_DEC::order_statistics, prefix_search = PB_DS_NODE_UPDATOR_TRAITS_C_DEC::prefix_search
prefix_search =
PB_DS_NODE_UPDATOR_TRAITS_C_DEC::prefix_search
}; };
template<typename T> template<typename T>
struct erase_if_fn : public regression_test_erase_if_fn< struct erase_if_fn : public regression_test_erase_if_fn<T>
T> { };
{
};
static size_t static size_t
erase_if(native_type& r_native_c) erase_if(native_type& r_native_c)
{ {
typedef typedef regression_test_erase_if_fn<typename native_type::value_type> erase_if_fn;
regression_test_erase_if_fn<
typename native_type::value_type>
erase_if_fn;
typename native_type::iterator it = r_native_c.begin(); typename native_type::iterator it = r_native_c.begin();
size_t num_ersd = 0; size_t num_ersd = 0;
while (it != r_native_c.end()) while (it != r_native_c.end())
if (erase_if_fn()(*it)) if (erase_if_fn()(*it))
{ {
++num_ersd; ++num_ersd;
r_native_c.erase(it); r_native_c.erase(it);
it = r_native_c.begin(); it = r_native_c.begin();
} }
else else
++it; ++it;
return num_ersd;
return (num_ersd);
} }
static void static void
...@@ -190,14 +163,14 @@ namespace pb_ds ...@@ -190,14 +163,14 @@ namespace pb_ds
static key_type static key_type
generate_key(Gen& r_gen, size_t max) generate_key(Gen& r_gen, size_t max)
{ {
return (PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max)); return PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max);
} }
template<typename Gen> template<typename Gen>
static value_type static value_type
generate_value(Gen& r_gen, size_t max) generate_value(Gen& r_gen, size_t max)
{ {
return (PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max)); return PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max);
} }
static const_key_reference static const_key_reference
...@@ -209,81 +182,70 @@ namespace pb_ds ...@@ -209,81 +182,70 @@ namespace pb_ds
static native_key_type static native_key_type
native_key(const_key_reference r_key) native_key(const_key_reference r_key)
{ {
return (native_type_traits_base::native_key(r_key)); return native_type_traits_base::native_key(r_key);
} }
static native_value_type static native_value_type
native_value(const_reference r_val) native_value(const_reference r_val)
{ {
return (native_type_traits_base::native_value(r_val)); return native_type_traits_base::native_value(r_val);
} }
static const native_key_type& static const native_key_type&
extract_native_key(const native_value_type& r_val) extract_native_key(const native_value_type& r_val)
{ {
return (native_type_traits_base::extract_key(r_val)); return native_type_traits_base::extract_key(r_val);
} }
static bool static bool
cmp(const_reference r_val, const native_value_type& r_native_val) cmp(const_reference r_val, const native_value_type& r_native_val)
{ {
return (val_to_string(r_val) == return val_to_string(r_val) == native_val_to_string(r_native_val);
native_val_to_string(r_native_val));
} }
static std::string static std::string
val_to_string(const_reference r_val) val_to_string(const_reference r_val)
{ {
return (to_string(r_val)); return to_string(r_val);
} }
static std::string static std::string
key_to_string(const_key_reference r_key) key_to_string(const_key_reference r_key)
{ {
return (to_string(r_key)); return to_string(r_key);
} }
static std::string static std::string
native_val_to_string(const native_value_type& r_native_val) native_val_to_string(const native_value_type& r_native_val)
{ {
return (to_string(r_native_val)); return to_string(r_native_val);
} }
static bool static bool
prefix_match(const_key_reference r_key, const std::string& r_native_key) prefix_match(const_key_reference r_key, const std::string& r_native_key)
{ {
const size_t native_substr_len = std::min( const size_t native_substr_len = std::min(r_key.length(),
r_key.length(),
r_native_key.length()); r_native_key.length());
const std::string native_substr = const std::string native_substr = r_native_key.substr(0,
r_native_key.substr(0, native_substr_len); native_substr_len);
return (native_substr == (const std::string& )r_key); return native_substr == (const std::string&) r_key;
} }
}; };
#undef PB_DS_TYPE_TRAITS_C_DEC #undef PB_DS_TYPE_TRAITS_C_DEC
#undef PB_DS_NATIVE_TYPE_TRAITS_C_DEC #undef PB_DS_NATIVE_TYPE_TRAITS_C_DEC
#undef PB_DS_RESIZE_TRAITS_C_DEC #undef PB_DS_RESIZE_TRAITS_C_DEC
#undef PB_DS_SET_LOADS_TRAITS_C_DEC #undef PB_DS_SET_LOADS_TRAITS_C_DEC
#undef PB_DS_SET_LOAD_TRAITS_C_DEC #undef PB_DS_SET_LOAD_TRAITS_C_DEC
#undef PB_DS_NODE_UPDATOR_TRAITS_C_DEC #undef PB_DS_NODE_UPDATOR_TRAITS_C_DEC
#undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_C_DEC
} // namespace detail } // namespace detail
} // namespace test
} // namespace test
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_REGRESSION_TEST_TRAIT_HPP #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment