sampled_t.cc
Go to the documentation of this file.
7 
8 #include <cassert>
9 #include <list>
10 #include <map>
11 #include <string>
12 #include <vector>
13 
14 using namespace art;
15 
16 namespace {
17  InputTag const invalid_tag{};
18 
19  template <typename T>
20  void
21  assert_sampled_allowed()
22  {
23  Sampled<T>{invalid_tag};
24  }
25 
26  template <typename T>
27  void
28  assert_sampled_forbidden() try {
29  Sampled<T>{invalid_tag};
30  assert(false && "Successful construction not expected.");
31  }
32  catch (Exception const& e) {
33  std::string const actual_msg{e.what()};
34  std::string const expected_msg{"An attempt was made to create the type"};
35  assert(actual_msg.find(expected_msg) != std::string::npos);
36  }
37 }
38 
39 int
41 {
42  assert_sampled_allowed<int>();
43  assert_sampled_allowed<std::vector<int>>();
44  assert_sampled_forbidden<Assns<int, double>>();
45  assert_sampled_forbidden<Assns<int, double, std::string>>();
46  assert_sampled_forbidden<Ptr<int>>();
47  assert_sampled_forbidden<PtrVector<int>>();
48  assert_sampled_forbidden<std::vector<Ptr<int>>>();
49  assert_sampled_forbidden<std::map<Ptr<int>, Ptr<double>>>();
50  assert_sampled_forbidden<std::list<Ptr<int>>>();
51  assert_sampled_forbidden<std::vector<std::vector<std::vector<Ptr<int>>>>>();
52 }
std::string string
Definition: nybbler.cc:12
int main()
Definition: sampled_t.cc:40
const double e
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66