Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/googletest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-11-07 20:36:17 +0300
committerCopybara-Service <copybara-worker@google.com>2022-11-07 20:36:56 +0300
commit386c7665f5cf1f772f5877cdb32070d8052041a9 (patch)
tree5d23f907d36827f3a70876941d3fc5cc3b3af4c2
parenta4f02ef38981350c9d673b9909559c7a86420d7a (diff)
RecordProperty serializes ints and 64-bit ints, including size_ts
PiperOrigin-RevId: 486685761 Change-Id: I164d2646e65670d341dbf437ee571953c456677a
-rw-r--r--googletest/include/gtest/gtest.h3
-rw-r--r--googletest/src/gtest.cc10
-rw-r--r--googletest/test/gtest_xml_outfile2_test_.cc4
3 files changed, 9 insertions, 8 deletions
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 7963e8c7..55fdc601 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -50,6 +50,7 @@
#define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
#include <cstddef>
+#include <cstdint>
#include <limits>
#include <memory>
#include <ostream>
@@ -296,7 +297,7 @@ class GTEST_API_ Test {
// SetUp/TearDown method of Environment objects registered with Google
// 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, int value);
+ static void RecordProperty(const std::string& key, int64_t value);
protected:
// Creates a Test object.
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 38594528..2276d077 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -2444,12 +2444,10 @@ void Test::TearDown() {}
void Test::RecordProperty(const std::string& key, const std::string& value) {
UnitTest::GetInstance()->RecordProperty(key, value);
}
-
-// Allows user supplied key value pairs to be recorded for later output.
-void Test::RecordProperty(const std::string& key, int value) {
- Message value_message;
- value_message << value;
- RecordProperty(key, value_message.GetString().c_str());
+// We do not define a customary serialization except for integers,
+// but other values could be logged in this way.
+void Test::RecordProperty(const std::string& key, int64_t value) {
+ RecordProperty(key, (Message() << value).GetString());
}
namespace internal {
diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc
index f9a2a6e9..f743b31b 100644
--- a/googletest/test/gtest_xml_outfile2_test_.cc
+++ b/googletest/test/gtest_xml_outfile2_test_.cc
@@ -39,5 +39,7 @@ class PropertyTwo : public testing::Test {
};
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);
}