summaryrefslogtreecommitdiff
path: root/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
commit7dc7ac3cb20b7ef8e6febe0ac3bc430230f29893 (patch)
tree8f8f6241c8d337970dc397842482c4279e1ea9c0 /unittests/ADT/TwineTest.cpp
parentf00140c8e16936aac3f51cc5607168f6982a987a (diff)
downloadllvm-7dc7ac3cb20b7ef8e6febe0ac3bc430230f29893.tar.gz
llvm-7dc7ac3cb20b7ef8e6febe0ac3bc430230f29893.tar.bz2
llvm-7dc7ac3cb20b7ef8e6febe0ac3bc430230f29893.tar.xz
Support/ADT/Twine: Add toNullTerminatedStringRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120600 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT/TwineTest.cpp')
-rw-r--r--unittests/ADT/TwineTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/unittests/ADT/TwineTest.cpp b/unittests/ADT/TwineTest.cpp
index 61e8a0ac37..57f54cb006 100644
--- a/unittests/ADT/TwineTest.cpp
+++ b/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... :)