Functions
to_string_test.cc File Reference
#include "fhiclcpp/ParameterSet.h"
#include <cassert>
#include <string>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( void  )

Definition at line 7 of file to_string_test.cc.

8 {
9  cet::filepath_lookup policy("FHICL_FILE_PATH");
10  std::string in("Sample.cfg");
11 
12  auto const pset1 = fhicl::ParameterSet::make(in, policy);
13  auto const pset2 = fhicl::ParameterSet::make(pset1.to_string());
14 
15  assert(pset1 == pset2);
16 
17  assert(pset2.get<int>("a") == 1);
18  assert(pset2.get<unsigned int>("a") == 1);
19  assert(pset2.get<int>("b") == -1);
20  // assert(pset2.get<unsigned int>("b", 0) == 0);
21 
22  assert(pset2.get<double>("c") == 0.0);
23  assert(pset2.get<double>("d") == 0.5);
24 
25  assert(pset2.get<std::string>("e").compare("rain") == 0);
26  assert(pset2.get<std::string>("f").compare("32") == 0);
27  assert(pset2.get<int>("f") == 32);
28 
29  assert(pset2.get<std::vector<int>>("g")[2] == 3);
30 
31  assert(pset2.get<std::vector<fhicl::ParameterSet>>("h")[1]
32  .get<std::string>("h2")
33  .compare("h2") == 0);
34 
35  assert(pset2.get<fhicl::ParameterSet>("i")
36  .get<fhicl::ParameterSet>("i1")
37  .get<std::string>("i1_1")
38  .compare("test") == 0);
39 
40  return 0;
41 } // main()
std::string string
Definition: nybbler.cc:12
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
T get(std::string const &key) const
Definition: ParameterSet.h:271