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 | 763457e70bc9c5c2def89d24a133808b8a971f9f (patch) | |
tree | 377376c3b2be90bda1f666bec5aec817ffe5df1b /unittests/ADT | |
parent | 78a3dd8fe141f98aaf8fbd92cfb7c97d4ddf19d6 (diff) | |
download | external_llvm-763457e70bc9c5c2def89d24a133808b8a971f9f.zip external_llvm-763457e70bc9c5c2def89d24a133808b8a971f9f.tar.gz external_llvm-763457e70bc9c5c2def89d24a133808b8a971f9f.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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT')
-rw-r--r-- | unittests/ADT/TwineTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/unittests/ADT/TwineTest.cpp b/unittests/ADT/TwineTest.cpp index 50fdd2e..dae5fa0 100644 --- a/unittests/ADT/TwineTest.cpp +++ b/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. |