ptr_hash_t.cc
Go to the documentation of this file.
3 
4 #include <cassert>
5 #include <unordered_set>
6 
7 void
9 {
10  art::Ptr<int> def;
11  std::unordered_set<art::Ptr<int>> s;
12  // Make sure insertion works
13  s.insert(def);
14  assert(s.size() == 1);
15  // Make sure insertion of a second item doesn't change the set
16  s.insert(def);
17  assert(s.size() == 1);
18  // Make sure finding works.
19  assert(s.find(def) == s.begin());
20 
21  // Don't do this at home, kids. This is a wildly unsafe Ptr! It does
22  // suffice for testing the hashing ability.
23  art::Ptr<int> p1(art::ProductID(234), nullptr, 7);
24  art::Ptr<int> p2(art::ProductID(234), nullptr, 7);
25  assert(def != p1);
26  assert(p1 == p2);
27  std::hash<art::Ptr<int>> hasher;
28  assert(hasher(def) != hasher(p1));
29  assert(hasher(p1) == hasher(p2));
30 
31  s.insert(p1);
32  assert(s.size() == 2);
33  assert(s.find(def) != s.end());
34  assert(s.find(p1) != s.end());
35 }
36 
37 int
39 {
41 }
void unordered_set_test()
Definition: ptr_hash_t.cc:8
int main()
Definition: ptr_hash_t.cc:38
Definition: fwd.h:31
static QCString * s
Definition: config.cpp:1042