File indexing completed on 2025-09-12 10:00:48
0001 #include "catch.hpp"
0002 namespace trigger_results_based_event_selector_utils {
0003
0004 void remove_whitespace(std::string& s);
0005
0006 typedef std::pair<std::string, std::string> parsed_path_spec_t;
0007 void parse_path_spec(std::string const& path_spec, parsed_path_spec_t& output);
0008 }
0009
0010 using namespace trigger_results_based_event_selector_utils;
0011 TEST_CASE("test TriggerResultsBasedEventSelector utilities", "[TriggerResultsBasedEventSelectorUtils]") {
0012 SECTION("remove whitespace") {
0013 std::string a("noblanks");
0014 std::string b("\t no blanks \t");
0015
0016 remove_whitespace(b);
0017 CHECK(a == b);
0018 }
0019 SECTION("test_parse_path_spec") {
0020 std::vector<std::string> paths;
0021 paths.push_back("a:p1");
0022 paths.push_back("b:p2");
0023 paths.push_back(" c");
0024 paths.push_back("ddd\t:p3");
0025 paths.push_back("eee: p4 ");
0026
0027 std::vector<parsed_path_spec_t> parsed(paths.size());
0028 for (size_t i = 0; i < paths.size(); ++i) {
0029 parse_path_spec(paths[i], parsed[i]);
0030 }
0031
0032 CHECK(parsed[0].first == "a");
0033 CHECK(parsed[0].second == "p1");
0034 CHECK(parsed[1].first == "b");
0035 CHECK(parsed[1].second == "p2");
0036 CHECK(parsed[2].first == "c");
0037 CHECK(parsed[2].second.empty());
0038 CHECK(parsed[3].first == "ddd");
0039 CHECK(parsed[3].second == "p3");
0040 CHECK(parsed[4].first == "eee");
0041 CHECK(parsed[4].second == "p4");
0042 }
0043 }