RecordProperty serializes ints and 64-bit ints, including size_ts
PiperOrigin-RevId: 486685761 Change-Id: I164d2646e65670d341dbf437ee571953c456677a
This commit is contained in:
parent
a4f02ef389
commit
386c7665f5
@ -50,6 +50,7 @@
|
|||||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
|
#define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -296,7 +297,7 @@ class GTEST_API_ Test {
|
|||||||
// SetUp/TearDown method of Environment objects registered with Google
|
// SetUp/TearDown method of Environment objects registered with Google
|
||||||
// Test) will be output as attributes of the <testsuites> element.
|
// Test) will be output as attributes of the <testsuites> element.
|
||||||
static void RecordProperty(const std::string& key, const std::string& value);
|
static void RecordProperty(const std::string& key, const std::string& value);
|
||||||
static void RecordProperty(const std::string& key, int value);
|
static void RecordProperty(const std::string& key, int64_t value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Creates a Test object.
|
// Creates a Test object.
|
||||||
|
@ -2444,12 +2444,10 @@ void Test::TearDown() {}
|
|||||||
void Test::RecordProperty(const std::string& key, const std::string& value) {
|
void Test::RecordProperty(const std::string& key, const std::string& value) {
|
||||||
UnitTest::GetInstance()->RecordProperty(key, value);
|
UnitTest::GetInstance()->RecordProperty(key, value);
|
||||||
}
|
}
|
||||||
|
// We do not define a customary serialization except for integers,
|
||||||
// Allows user supplied key value pairs to be recorded for later output.
|
// but other values could be logged in this way.
|
||||||
void Test::RecordProperty(const std::string& key, int value) {
|
void Test::RecordProperty(const std::string& key, int64_t value) {
|
||||||
Message value_message;
|
RecordProperty(key, (Message() << value).GetString());
|
||||||
value_message << value;
|
|
||||||
RecordProperty(key, value_message.GetString().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -39,5 +39,7 @@ class PropertyTwo : public testing::Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(PropertyTwo, TestSomeProperties) {
|
TEST_F(PropertyTwo, TestSomeProperties) {
|
||||||
RecordProperty("TestSomeProperty", 2);
|
// Validate we can write an unsigned size_t as a property
|
||||||
|
size_t prop_two = 2;
|
||||||
|
RecordProperty("TestSomeProperty", prop_two);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user