printing_helpers_t.cc
Go to the documentation of this file.
2 #include "fhiclcpp/exception.h"
3 
4 #include <cassert>
5 #include <string>
6 
7 using namespace fhicl::detail;
8 
9 namespace {
10  bool
11  not_sequence_element(std::string const& name) try {
13  return false;
14  }
15  catch (fhicl::exception const& e) {
16  std::string_view msg{e.what()};
17  return e.categoryCode() == fhicl::error::other &&
18  msg.find("does not correspond to a sequence element") !=
19  std::string::npos;
20  }
21  catch (...) {
22  return false;
23  }
24 }
25 
26 int
28 {
29  assert(index_for_sequence_element("a[0]") == 0);
30  assert(index_for_sequence_element("a[5][7]") == 7);
31  assert(index_for_sequence_element("a.b.c[15]") == 15);
32  assert(not_sequence_element("a"));
33  assert(not_sequence_element("a]19["));
34 }
static QCString name
Definition: declinfo.cpp:673
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
int main()
const double e
std::size_t index_for_sequence_element(std::string const &name)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33