aboutsummaryrefslogtreecommitdiff
path: root/boost/common/unordered/test.hxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-03-02 18:02:32 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-03-08 18:13:49 +0200
commit9bdf5bcbeb1b8748cdc269b04f9cbb5ca63630bf (patch)
tree0f14159b46315c64207a289ddf460c2a485916de /boost/common/unordered/test.hxx
parenta236e04a281da3ce9b96418ed81a1dff85008da5 (diff)
Add boost/common/smart-ptr and boost/common/unordered tests
Diffstat (limited to 'boost/common/unordered/test.hxx')
-rw-r--r--boost/common/unordered/test.hxx107
1 files changed, 107 insertions, 0 deletions
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 <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST_HXX
+#define TEST_HXX
+
+#include <boost/unordered_set.hpp>
+#include <boost/unordered_map.hpp>
+
+#include <odb/core.hxx>
+
+#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<int> num_set;
+typedef unordered_set<std::string> str_set;
+typedef unordered_multiset<comp> comp_multiset;
+
+using boost::unordered_map;
+using boost::unordered_multimap;
+
+typedef unordered_map<int, std::string> num_str_map;
+typedef unordered_map<std::string, int> str_num_map;
+typedef unordered_map<int, comp> num_comp_map;
+typedef unordered_multimap<comp, std::string> 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