A copyable object representing a user specified test property which can be output as a key/value string pair. Don't inherit from TestProperty as its destructor is not virtual.
| 12978 | // |
| 12979 | // Don't inherit from TestProperty as its destructor is not virtual. |
| 12980 | class TestProperty { |
| 12981 | public: |
| 12982 | // C'tor. TestProperty does NOT have a default constructor. |
| 12983 | // Always use this constructor (with parameters) to create a |
| 12984 | // TestProperty object. |
| 12985 | TestProperty(const std::string& a_key, const std::string& a_value) : |
| 12986 | key_(a_key), value_(a_value) { |
| 12987 | } |
| 12988 | |
| 12989 | // Gets the user supplied key. |
| 12990 | const char* key() const { |
| 12991 | return key_.c_str(); |
| 12992 | } |
| 12993 | |
| 12994 | // Gets the user supplied value. |
| 12995 | const char* value() const { |
| 12996 | return value_.c_str(); |
| 12997 | } |
| 12998 | |
| 12999 | // Sets a new value, overriding the one supplied in the constructor. |
| 13000 | void SetValue(const std::string& new_value) { |
| 13001 | value_ = new_value; |
| 13002 | } |
| 13003 | |
| 13004 | private: |
| 13005 | // The key supplied by the user. |
| 13006 | std::string key_; |
| 13007 | // The value supplied by the user. |
| 13008 | std::string value_; |
| 13009 | }; |
| 13010 | |
| 13011 | // The result of a single Test. This includes a list of |
| 13012 | // TestPartResults, a list of TestProperties, a count of how many |