-
-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Support calling a const NumberToString, add unit tests + style improvements #2256
ENH: Support calling a const NumberToString, add unit tests + style improvements #2256
Conversation
Supported calling a `const` NumberToString function object, by declaring all `NumberToString::operator()` overloads `const`. Added various GoogleTest unit tests, which do call `const` NumberToString objects.
Various style improvements of the implementation of the `NumberToString<TValue>` specializations for floating point numbers: - Did clean up the #include's. - Removed unnecessary builder.Reset() calls. (`StringBuilder::Reset()` only just sets the internal position to zero, but that is already taken care of by the constructor of `StringBuilder`.) - Added local helper function, `FloatingPointNumberToString(val)`, sharing code between `float` and `double` specialization. - Reduced size of local buffer (`buf`) from 256 to 32 chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see the improved coverage 💚
FYI, some interesting differences between the output of
As produced by the following code:
|
Now I see your comment. Perhaps in the case of
|
If you wish to add some more unit tests, you can do so in a new PR specifically aimed at increasing test coverage. But that does not seem necessary. |
@dzenanz Thanks, I think it isn't necessary either to add more unit tests. 😃 I did add them especially to ensure that the STYLE commit c00531f wouldn't change the existing behavior. And that should be fine, as the tests are passed now both before and after the STYLE commit. BTW, the tests might eventually break if the floating point format of |
FYI, I just submitted a related issue: "Maximum string length DoubleToStringConverter::EcmaScriptConverter() ToShortest? 26 chars?", google/double-conversion#146 |
Last weekend I submitted a related pull request to Google's double-conversion library, which aims to allow further simplifying the implementation of google/double-conversion#159 "Add |
Supported calling a
const
NumberToString function object, by declaring allNumberToString::operator()
overloadsconst
.Added various GoogleTest unit tests, which do call
const
NumberToString objects.Did various style improvements, including a reduction of the
buf
size, and removal ofbuilder.Reset()
calls from the implementation ofNumberToString
.