Functions
ptr_hash_t.cc File Reference
#include "canvas/Persistency/Common/Ptr.h"
#include "canvas/Persistency/Provenance/ProductID.h"
#include <cassert>
#include <unordered_set>

Go to the source code of this file.

Functions

void unordered_set_test ()
 
int main ()
 

Function Documentation

int main ( void  )

Definition at line 38 of file ptr_hash_t.cc.

39 {
41 }
void unordered_set_test()
Definition: ptr_hash_t.cc:8
void unordered_set_test ( )

Definition at line 8 of file ptr_hash_t.cc.

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 }
Definition: fwd.h:31
static QCString * s
Definition: config.cpp:1042