berkoo / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

RecordProperty support for double/bool/char/etc #199

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Pass double value into RecordProperty, get compiler warning
Warning: passing `double' for converting 2 of `static void 
testing::Test::RecordProperty(const 
char*, int)'
due to no double option 
2. RecordProperty seems to currently support int/char* 
./gtest/gtest.h:  static void RecordProperty(const char* key, const char* 
value);
./gtest/gtest.h:  static void RecordProperty(const char* key, int value)

What is the expected output? What do you see instead?
Would be cool to have versions of the method for different types, so wouldnt 
have to convert 
double to char* outside the method, in order to see the result in the XML file. 
Other types could 
be supported too.

What version of the product are you using? On what operating system?
Linux, gtest 1.3.0

Original issue reported on code.google.com by simonsha...@gmail.com on 18 Sep 2009 at 10:09

GoogleCodeExporter commented 9 years ago
Probably we should templatize it:

template <typename T>
void RecordProperty(const char* name, const T& value);

The implementation will just stream value to a stringstream and then extract 
the string.

This allows any printable type to be used in RecordProperty.

Original comment by zhanyong...@gmail.com on 18 Sep 2009 at 5:14