Details
- Reviewers
jhenderson - Commits
- rG8ca7d2a1ee96: [unittest, ADT] Add unit tests for itostr & utostr
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/unittests/ADT/StringExtrasTest.cpp | ||
---|---|---|
198 | Since there's no comment, I'm not sure whether it is supported by the API or not. I'd be tempted to add an assert and a comment not to support it. |
llvm/unittests/ADT/StringExtrasTest.cpp | ||
---|---|---|
195–196 | Here, and in the below cases using the max/min values, I wonder whether it would be more robust to write something like: EXPECT_EQ(std::to_string(MaxUint64), utostr(MaxUint64)); EXPECT_EQ("-" + std::to_string(MaxUint64), utostr(MaxUint64, /*isNeg=*/true); etc. I'd expect them to produce identical output, but it also is easier to confirm the expected number. It also removes any concerns about numeric representation (2's complement etc). | |
198 | I'm inclined to leave it as-is. It's possible it was a simple oversight by the original developer, but I think it's okay to permit it for consistency. People could be using it in the sense of "subtract 0" rather than "negative 0" in theory, apart from anything else. |
llvm/unittests/ADT/StringExtrasTest.cpp | ||
---|---|---|
195–196 | It's what I did originally but I was not sure if it was fine to rely on std::to_string being correct. |
LGTM.
llvm/unittests/ADT/StringExtrasTest.cpp | ||
---|---|---|
195–196 | I think if we can't rely on standard library functions doing the right thing, we're in trouble... |
Here, and in the below cases using the max/min values, I wonder whether it would be more robust to write something like:
etc.
I'd expect them to produce identical output, but it also is easier to confirm the expected number. It also removes any concerns about numeric representation (2's complement etc).