Functions
ParameterSet_get_artInputTag_t.cc File Reference
#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "fhiclcpp/exception.h"
#include <cassert>
#include <sstream>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( void  )

Definition at line 26 of file ParameterSet_get_artInputTag_t.cc.

27 {
28  //===========================================================
29  // Test 1-argument InputTag c'tor
30  //===========================================================
31 
33  pset.put<std::string>("first_key", "label:instance:processName");
34 
35  std::vector<std::string> vs;
36  for (unsigned i(0); i != 10; ++i) {
37  std::ostringstream value;
38  value << "label" << i << ":"
39  << "instance" << i << ":"
40  << "processName" << i;
41  vs.emplace_back(value.str());
42  }
43  pset.put("second_key", vs);
44 
45  auto const tag = pset.get<art::InputTag>("first_key");
46  auto const vec_tags = pset.get<std::vector<art::InputTag>>("second_key");
47 
48  auto const vec_tags_empty =
49  pset.get("third_key", std::vector<art::InputTag>{});
50 
51  assert(vec_tags_empty.empty());
52 
53  std::vector<art::InputTag> vtag;
54  assert(pset.get_if_present("second_key", vtag));
55 
56  //===========================================================
57  // Test multi-argument constructors
58  //===========================================================
59 
60  pset.put<std::vector<std::string>>("multi1", {"label", "instance"});
61  pset.put<std::vector<std::string>>("multi2",
62  {"label", "instance", "process"});
63  pset.put<std::vector<std::string>>("multierr1", {"label:something:else"});
64  pset.put<std::vector<std::string>>(
65  "multierr2", {"label", "instance", "process", "something", "else"});
66 
67  retrieve(pset, "multi1");
68  retrieve(pset, "multi2");
69  retrieve(pset, "multierr1", should_fail);
70  retrieve(pset, "multierr2", should_fail);
71 }
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:224
void put(std::string const &key)