diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-29 07:08:44 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-29 07:08:44 +0000 |
commit | b49994ad7edf36c8377460d70e9f3069de41a8f1 (patch) | |
tree | 811cdf224601b80ae60c4814bfc278e3c91207f6 /llvm/unittests/ADT/TwineTest.cpp | |
parent | a94f58aee5c813d0bd8f2da4788043ce42c1d475 (diff) | |
download | llvm-b49994ad7edf36c8377460d70e9f3069de41a8f1.zip llvm-b49994ad7edf36c8377460d70e9f3069de41a8f1.tar.gz llvm-b49994ad7edf36c8377460d70e9f3069de41a8f1.tar.bz2 |
Twines: Support numeric conversion directly (uitostr, etc).
- Provides static constructors for doing number to string conversions without
using temporaries.
- There are several ways to do this, I think given the Twine constraints this
is the simplest one.
- One FIXME for fast number -> hex conversion.
- Added another comment on one last major bit of perf work Twines need, which
is to make raw_svector_ostream more efficient.
llvm-svn: 77445
Diffstat (limited to 'llvm/unittests/ADT/TwineTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/TwineTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/TwineTest.cpp b/llvm/unittests/ADT/TwineTest.cpp index 50fdd2e..dae5fa0 100644 --- a/llvm/unittests/ADT/TwineTest.cpp +++ b/llvm/unittests/ADT/TwineTest.cpp @@ -30,6 +30,18 @@ TEST(TwineTest, Construction) { EXPECT_EQ("hi", Twine(StringRef("hithere", 2)).str()); } +TEST(TwineTest, Numbers) { + EXPECT_EQ("123", Twine::utostr(123).str()); + EXPECT_EQ("-123", Twine::itostr(-123).str()); + EXPECT_EQ("123", Twine::utostr(123).str()); + EXPECT_EQ("-123", Twine::itostr(-123).str()); + EXPECT_EQ("123", Twine::utostr((char) 123).str()); + EXPECT_EQ("-123", Twine::itostr((char) -123).str()); + + EXPECT_EQ("7B", Twine::utohexstr(123).str()); + EXPECT_EQ("FFFFFFFFFFFFFF85", Twine::itohexstr(-123).str()); +} + TEST(TwineTest, Concat) { // Check verse repr, since we care about the actual representation not just // the result. |