aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/TwineTest.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-01 20:37:30 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-01 20:37:30 +0000
commitf2cc8287ed6a37a6141a60c83f7e30fe288e9606 (patch)
tree830ab6ab3c3b4adcc9b946100cd7dba94b18c8a7 /llvm/unittests/ADT/TwineTest.cpp
parentaa49ecc4586af252e2841c2bc8f5689526da7a4b (diff)
downloadllvm-f2cc8287ed6a37a6141a60c83f7e30fe288e9606.zip
llvm-f2cc8287ed6a37a6141a60c83f7e30fe288e9606.tar.gz
llvm-f2cc8287ed6a37a6141a60c83f7e30fe288e9606.tar.bz2
Support/ADT/Twine: Add toNullTerminatedStringRef.
llvm-svn: 120600
Diffstat (limited to 'llvm/unittests/ADT/TwineTest.cpp')
-rw-r--r--llvm/unittests/ADT/TwineTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/TwineTest.cpp b/llvm/unittests/ADT/TwineTest.cpp
index 61e8a0a..57f54cb 100644
--- a/llvm/unittests/ADT/TwineTest.cpp
+++ b/llvm/unittests/ADT/TwineTest.cpp
@@ -9,6 +9,7 @@
#include "gtest/gtest.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -69,6 +70,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... :)