From 9bdf5bcbeb1b8748cdc269b04f9cbb5ca63630bf Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Wed, 2 Mar 2011 18:02:32 +0200 Subject: Add boost/common/smart-ptr and boost/common/unordered tests --- boost/common/unordered/test.hxx | 107 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 boost/common/unordered/test.hxx (limited to 'boost/common/unordered/test.hxx') diff --git a/boost/common/unordered/test.hxx b/boost/common/unordered/test.hxx new file mode 100644 index 0000000..02ed5bd --- /dev/null +++ b/boost/common/unordered/test.hxx @@ -0,0 +1,107 @@ +// file : boost/common/unordered/test.hxx +// author : Constantin Michael +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#pragma db value +struct comp +{ + comp () {} + comp (int n, const std::string& s) : num (n), str (s) {} + + #pragma db column("number") + int num; + std::string str; +}; + +inline bool +operator== (const comp& x, const comp& y) +{ + return x.num == y.num && x.str == y.str; +} + +inline bool +operator< (const comp& x, const comp& y) +{ + return x.num != y.num ? x.num < y.num : x.str < y.str; +} + +inline std::size_t +hash_value (const comp& x) +{ + std::size_t seed = 0; + boost::hash_combine (seed, x.num); + boost::hash_combine (seed, x.str); + return seed; +} + +using boost::unordered_set; +using boost::unordered_multiset; + +typedef unordered_set num_set; +typedef unordered_set str_set; +typedef unordered_multiset comp_multiset; + +using boost::unordered_map; +using boost::unordered_multimap; + +typedef unordered_map num_str_map; +typedef unordered_map str_num_map; +typedef unordered_map num_comp_map; +typedef unordered_multimap comp_str_multimap; + +#pragma db object +struct object +{ + object () + { + } + + object (const std::string& id) + : id (id) + { + } + + + #pragma db id + std::string id; + + // set + // + num_set ns; + str_set ss; + comp_multiset cms; + + // map + // + num_str_map nsm; + str_num_map snm; + num_comp_map ncm; + comp_str_multimap csmm; +}; + +inline bool +operator== (const object& x, const object& y) +{ + return + x.id == y.id && + + x.ns == y.ns && + x.ss == y.ss && + x.cms == y.cms && + + x.nsm == y.nsm && + x.snm == y.snm && + x.ncm == y.ncm && + x.csmm == y.csmm; +} + +#endif // TEST_HXX -- cgit v1.1