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#include <boost/regex.hpp>
40#include <vector>
41
42namespace Nektar
43{
44/**
45 * @brief Data structure for a Regex value to match.
46 */
48{
50 {
51 }
52
53 MetricRegexFieldValue(std::string value) : m_value(value)
54 {
55 }
56
57 std::string m_value = "";
58 bool m_useTolerance = false;
59 double m_tolerance = 0.0;
60
61 bool m_useIntTolerance = false;
63};
64
65class MetricRegex : public Metric
66{
67public:
68 virtual ~MetricRegex()
69 {
70 }
71
72 static MetricSharedPtr create(TiXmlElement *metric, bool generate)
73 {
74 return MetricSharedPtr(new MetricRegex(metric, generate));
75 }
76
77 static std::string type;
78
79protected:
80 /// Storage for the boost regex.
81 boost::regex m_regex;
82 /// Stores the multiple matches defined in each <MATCH> tag.
83 std::vector<std::vector<MetricRegexFieldValue>> m_matches;
84 /// If true, regex matches may be in any order in output
85 bool m_unordered = false;
86 /// If true, use stderr for testing/generation instead of stdout.
87 bool m_useStderr = false;
88
89 MetricRegex(TiXmlElement *metric, bool generate);
90
91 virtual bool v_Test(std::istream &pStdout, std::istream &pStderr);
92 virtual void v_Generate(std::istream &pStdout, std::istream &pStderr);
93};
94} // namespace Nektar
95
96#endif
Base class for all metrics. Metric represents a test metric that can be used to evaluate the function...
Definition: Metric.h:70
bool m_unordered
If true, regex matches may be in any order in output.
Definition: MetricRegex.h:85
boost::regex m_regex
Storage for the boost regex.
Definition: MetricRegex.h:81
static std::string type
Definition: MetricRegex.h:77
MetricRegex(TiXmlElement *metric, bool generate)
Constructor.
Definition: MetricRegex.cpp:51
virtual void v_Generate(std::istream &pStdout, std::istream &pStderr)
Test output against a regex expression and set of matches.
virtual bool v_Test(std::istream &pStdout, std::istream &pStderr)
Test output against a regex expression and set of matches.
std::vector< std::vector< MetricRegexFieldValue > > m_matches
Stores the multiple matches defined in each <MATCH> tag.
Definition: MetricRegex.h:83
bool m_useStderr
If true, use stderr for testing/generation instead of stdout.
Definition: MetricRegex.h:87
static MetricSharedPtr create(TiXmlElement *metric, bool generate)
Definition: MetricRegex.h:72
virtual ~MetricRegex()
Definition: MetricRegex.h:68
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< Metric > MetricSharedPtr
A shared pointer to an EquationSystem object.
Definition: Metric.h:129
Data structure for a Regex value to match.
Definition: MetricRegex.h:48
MetricRegexFieldValue(std::string value)
Definition: MetricRegex.h:53