Nektar++
MetricRegex.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: MetricRegex.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Definition of the regular-expression metric.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_TESTS_METRICREGEX_H
36#define NEKTAR_TESTS_METRICREGEX_H
37
38#include <Metric.h>
39
40#include <regex>
41#include <vector>
42
43namespace Nektar
44{
45/**
46 * @brief Data structure for a Regex value to match.
47 */
49{
51 {
52 }
53
54 MetricRegexFieldValue(std::string value) : m_value(value)
55 {
56 }
57
58 std::string m_value = "";
59 bool m_useTolerance = false;
60 double m_tolerance = 0.0;
61
62 bool m_useIntTolerance = false;
64};
65
66class MetricRegex : public Metric
67{
68public:
69 ~MetricRegex() override
70 {
71 }
72
73 static MetricSharedPtr create(TiXmlElement *metric, bool generate)
74 {
75 return MetricSharedPtr(new MetricRegex(metric, generate));
76 }
77
78 static std::string type;
79
80protected:
81 /// Storage for the boost regex.
82 std::regex m_regex;
83 /// Stores the multiple matches defined in each <MATCH> tag.
84 std::vector<std::vector<MetricRegexFieldValue>> m_matches;
85 /// If true, regex matches may be in any order in output
86 bool m_unordered = false;
87 /// If true, use stderr for testing/generation instead of stdout.
88 bool m_useStderr = false;
89
90 MetricRegex(TiXmlElement *metric, bool generate);
91
92 bool v_Test(std::istream &pStdout, std::istream &pStderr) override;
93 void v_Generate(std::istream &pStdout, std::istream &pStderr) override;
94};
95} // namespace Nektar
96
97#endif
Base class for all metrics. Metric represents a test metric that can be used to evaluate the function...
Definition: Metric.h:65
bool m_unordered
If true, regex matches may be in any order in output.
Definition: MetricRegex.h:86
void v_Generate(std::istream &pStdout, std::istream &pStderr) override
Test output against a regex expression and set of matches.
static std::string type
Definition: MetricRegex.h:78
MetricRegex(TiXmlElement *metric, bool generate)
Constructor.
Definition: MetricRegex.cpp:51
~MetricRegex() override
Definition: MetricRegex.h:69
std::vector< std::vector< MetricRegexFieldValue > > m_matches
Stores the multiple matches defined in each <MATCH> tag.
Definition: MetricRegex.h:84
bool m_useStderr
If true, use stderr for testing/generation instead of stdout.
Definition: MetricRegex.h:88
static MetricSharedPtr create(TiXmlElement *metric, bool generate)
Definition: MetricRegex.h:73
std::regex m_regex
Storage for the boost regex.
Definition: MetricRegex.h:82
bool v_Test(std::istream &pStdout, std::istream &pStderr) override
Test output against a regex expression and set of matches.
std::shared_ptr< Metric > MetricSharedPtr
A shared pointer to an EquationSystem object.
Definition: Metric.h:124
Data structure for a Regex value to match.
Definition: MetricRegex.h:49
MetricRegexFieldValue(std::string value)
Definition: MetricRegex.h:54