Functions
registry_test.cc File Reference
#include "cetlib/registry.h"
#include "cetlib_except/exception.h"
#include <cstdlib>
#include <string>

Go to the source code of this file.

Functions

void ensure (int which, bool claim)
 
int main ()
 

Function Documentation

void ensure ( int  which,
bool  claim 
)

Definition at line 16 of file registry_test.cc.

17 {
18  if (not claim)
19  std::exit(which);
20 }
int main ( void  )

Definition at line 23 of file registry_test.cc.

24 {
25  int i;
26 
28  ensure(1, reg::empty());
29  ensure(2, reg::size() == 0);
30 
31  reg::put("one", 1);
32  reg::put("two", 2);
33  reg::put("three", 3);
34  ensure(3, reg::size() == 3);
35  reg::put("four", 4);
36  reg::put("five", 5);
37  reg::put("six", 6);
38  reg::put("seven", 7);
39  reg::put("eight", 8);
40  reg::put("nine", 9);
41  reg::put("zero", 0);
42 
43  ensure(11, !reg::empty());
44  ensure(12, reg::size() == 10);
45  ensure(13, reg::get("seven") == 7);
46  ensure(14, reg::get("five") == 5);
47  ensure(15, !reg::get("bleen", i));
48  ensure(16, reg::get("two", i) && i == 2);
49 
50  try {
51  reg::get("ten");
52  ensure(21, false);
53  }
54  catch (cet::exception const& e) {
55  ensure(22, e.category() == "cet::registry");
56  std::string s = e.explain_self();
57  ensure(23, s.find("not found in registry") != std::string::npos);
58  }
59  catch (...) {
60  ensure(24, false);
61  }
62 
63  return reg::get("zero");
64 
65 } // main()
std::string string
Definition: nybbler.cc:12
void ensure(int which, bool claim)
const double e
static collection_type const & get() noexcept
static size_type size()
static detail::must_have_id< K, V >::type put(V const &value)
cet::registry_via_id< success_t, val > reg
static QCString * s
Definition: config.cpp:1042
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33