Add Twine support for characters, and switch twine to use a union internally

to eliminate some casting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135888 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2011-07-24 20:44:30 +00:00
parent 81d686edbe
commit 3f25ee080c
3 changed files with 122 additions and 54 deletions

View File

@ -37,12 +37,16 @@ TEST(TwineTest, Numbers) {
EXPECT_EQ("-123", Twine(-123).str());
EXPECT_EQ("123", Twine(123).str());
EXPECT_EQ("-123", Twine(-123).str());
EXPECT_EQ("123", Twine((char) 123).str());
EXPECT_EQ("-123", Twine((signed char) -123).str());
EXPECT_EQ("7b", Twine::utohexstr(123).str());
}
TEST(TwineTest, Characters) {
EXPECT_EQ("x", Twine('x').str());
EXPECT_EQ("x", Twine(static_cast<unsigned char>('x')).str());
EXPECT_EQ("x", Twine(static_cast<signed char>('x')).str());
}
TEST(TwineTest, Concat) {
// Check verse repr, since we care about the actual representation not just
// the result.