exception_category_matcher.h
Go to the documentation of this file.
1 #ifndef cetlib_exception_category_matcher_h
2 #define cetlib_exception_category_matcher_h
3 ////////////////////////////////////////////////////////////////////////
4 // exception_category_matcher
5 //
6 // Utility for matching cet::exception categories when one is using the
7 // Catch unit testing package.
8 //
9 // Initialize with the string representation of the category to be
10 // matched.
11 //
12 // Composable with other bases of Catch::MatcherBase<cet::exception>
13 // such as cet::exception_message_matcher.
14 ////////////////////////////////////////////////////////////////////////
15 #include "cetlib_except/exception.h"
16 #include <catch/catch.hpp>
17 
18 #include <string>
19 
20 namespace cet {
21  class exception_category_matcher;
22 }
23 
25  : public Catch::MatcherBase<cet::exception> {
26 public:
28  : category_{std::move(category)}
29  {}
30 
31  bool
32  match(cet::exception const& e) const override
33  {
34  return e.category() == category_;
35  }
36 
38  describe() const override
39  {
40  using namespace std::string_literals;
41  std::string desc{"is of category \""s + category_ + '"'};
42  return desc;
43  }
44 
45 private:
47 };
48 
49 #endif /* cetlib_exception_category_matcher_h */
50 
51 // Local Variables:
52 // mode: c++
53 // End:
std::string describe() const override
exception_category_matcher(std::string category)
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
const XML_Char * s
Definition: expat.h:262
Float_t e
Definition: plot.C:35
bool match(cet::exception const &e) const override
enum BeamMode string