OTest2
A C++ testing framework
objectpath.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2.
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OTest2__INCLUDE_OTEST2_OBJECTPATH_H_
21 #define OTest2__INCLUDE_OTEST2_OBJECTPATH_H_
22 
23 #include <string>
24 
25 namespace OTest2 {
26 
27 class Parameters;
28 
32 class ObjectPath {
33  public:
34  struct Impl;
35 
36  private:
37  Impl* pimpl;
38 
39  public:
40  /* -- avoid copying */
41  ObjectPath(
42  const ObjectPath&) = delete;
44  const ObjectPath&) = delete;
45 
49  ObjectPath();
50 
56  explicit ObjectPath(
57  const std::string& full_path_);
58 
62  ~ObjectPath();
63 
69  void pushName(
70  const std::string& name_);
71 
75  void popName();
76 
83  void appendParameter(
84  const std::string& name_,
85  const std::string& value_);
86 
92  std::string getCurrentName() const;
93 
99  const Parameters& getCurrentParameters() const;
100 
106  std::string getCurrentPath() const;
107 
115  std::string getRegressionKey(
116  const std::string& local_key_) const;
117 
121  bool isPrefixOf(
122  const ObjectPath& path_) const noexcept;
123 };
124 
125 } /* -- namespace OTest2 */
126 
127 #endif /* -- OTest2__INCLUDE_OTEST2_OBJECTPATH_H_ */
OTest2::ObjectPath
This is a simple object keeping path to current testing object.
Definition: objectpath.h:32
OTest2::ObjectPath::popName
void popName()
Pop name of currently leaving testing object.
Definition: objectpath.cpp:93
OTest2::ObjectPath::operator=
ObjectPath & operator=(const ObjectPath &)=delete
OTest2::ObjectPath::getRegressionKey
std::string getRegressionKey(const std::string &local_key_) const
Create key of a regression test mark according to current object path.
Definition: objectpath.cpp:127
OTest2::ObjectPath::pushName
void pushName(const std::string &name_)
Push name of currently entering testing object.
Definition: objectpath.cpp:86
OTest2::ObjectPath::~ObjectPath
~ObjectPath()
Dtor.
Definition: objectpath.cpp:82
OTest2::ObjectPath::getCurrentName
std::string getCurrentName() const
Get name at the top of the stack.
Definition: objectpath.cpp:106
OTest2::Parameters
Generic parameters of a run of an testing object.
Definition: parameters.h:30
OTest2
Definition: assertbean.h:25
OTest2::ObjectPath::getCurrentParameters
const Parameters & getCurrentParameters() const
Get parameters of current object.
Definition: objectpath.cpp:112
OTest2::ObjectPath::ObjectPath
ObjectPath()
Ctor.
Definition: objectpath.cpp:56
OTest2::ObjectPath::appendParameter
void appendParameter(const std::string &name_, const std::string &value_)
Append parameter to current testing object.
Definition: objectpath.cpp:98
OTest2::ObjectPath::getCurrentPath
std::string getCurrentPath() const
Get path of current object.
Definition: objectpath.cpp:118
OTest2::ObjectPath::isPrefixOf
bool isPrefixOf(const ObjectPath &path_) const noexcept
Tell us whether this object is a prefix of specified path_.
Definition: objectpath.cpp:143