X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FADT%2FTwineTest.cpp;h=39d3b561b66897684a5a5e64353a4475806b0537;hb=1b3e3eef1fb51ace32b32e5ca217dacb03333b13;hp=61e8a0ac37cbbccfe7cd1cb13103cffaef24b276;hpb=0fffbafa9609e0e289ff3120ab9e23d244c1dbc0;p=oota-llvm.git diff --git a/unittests/ADT/TwineTest.cpp b/unittests/ADT/TwineTest.cpp index 61e8a0ac37c..39d3b561b66 100644 --- a/unittests/ADT/TwineTest.cpp +++ b/unittests/ADT/TwineTest.cpp @@ -7,9 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "gtest/gtest.h" #include "llvm/ADT/Twine.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" +#include "gtest/gtest.h" using namespace llvm; namespace { @@ -36,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('x')).str()); + EXPECT_EQ("x", Twine(static_cast('x')).str()); +} + TEST(TwineTest, Concat) { // Check verse repr, since we care about the actual representation not just // the result. @@ -69,6 +74,13 @@ TEST(TwineTest, Concat) { repr(Twine("a").concat(Twine("b").concat(Twine("c"))))); } +TEST(TwineTest, toNullTerminatedStringRef) { + SmallString<8> storage; + EXPECT_EQ(0, *Twine("hello").toNullTerminatedStringRef(storage).end()); + EXPECT_EQ(0, + *Twine(StringRef("hello")).toNullTerminatedStringRef(storage).end()); +} + // I suppose linking in the entire code generator to add a unit test to check // the code size of the concat operation is overkill... :)