summaryrefslogtreecommitdiffstats
path: root/googletest/include
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@google.com>2023-02-02 17:31:10 (GMT)
committerCopybara-Service <copybara-worker@google.com>2023-02-02 17:31:44 (GMT)
commitdeaf5615f18dd3b051006ba7326e2a976f5dff46 (patch)
tree5b9e60a5421cfbbce158adc605c44439ecee19e0 /googletest/include
parent4f7c63d991824b8034a81a0dd91f8b90a20d7806 (diff)
downloadgoogletest-deaf5615f18dd3b051006ba7326e2a976f5dff46.zip
googletest-deaf5615f18dd3b051006ba7326e2a976f5dff46.tar.gz
googletest-deaf5615f18dd3b051006ba7326e2a976f5dff46.tar.bz2
Fix -Wsign-conversion warnings
googletest/test/gtest_xml_outfile2_test_.cc:48:39: warning: implicit conversion turns floating-point number into integer: 'float' to 'int64_t' (aka 'long') [-Wfloat-conversion] RecordProperty("TestFloatProperty", float_prop); ~~~~~~~~~~~~~~ ^~~~~~~~~~ googletest/test/gtest_xml_outfile2_test_.cc:51:40: warning: implicit conversion turns floating-point number into integer: 'double' to 'int64_t' (aka 'long') [-Wfloat-conversion] RecordProperty("TestDoubleProperty", double_prop); ~~~~~~~~~~~~~~ ^~~~~~~~~~~ googletest/test/gtest_xml_outfile2_test_.cc:57:39: warning: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'int64_t' (aka 'long') [-Wsign-conversion] RecordProperty("TestSizetProperty", size_t_prop); ~~~~~~~~~~~~~~ ^~~~~~~~~~~ PiperOrigin-RevId: 506644143 Change-Id: I9c2cd5f52daebe25e73bb97f696687797ed2cabf
Diffstat (limited to 'googletest/include')
-rw-r--r--googletest/include/gtest/gtest.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index f99df35..35c0802 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -297,7 +297,13 @@ 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, int64_t value);
+ // We do not define a custom serialization except for values that can be
+ // converted to int64_t, but other values could be logged in this way.
+ template <typename T, std::enable_if_t<std::is_convertible<T, int64_t>::value,
+ bool> = true>
+ static void RecordProperty(const std::string& key, const T& value) {
+ RecordProperty(key, (Message() << static_cast<int64_t>(value)).GetString());
+ }
protected:
// Creates a Test object.