Support writing a StringRef to a raw_ostream directly.
llvm-svn: 76754
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index bb46dc0..ba2216d 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -9,6 +9,7 @@
#include "gtest/gtest.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
@@ -66,6 +67,11 @@
EXPECT_TRUE(Str.startswith("he"));
EXPECT_FALSE(Str.startswith("helloworld"));
EXPECT_FALSE(Str.startswith("hi"));
+
+ std::string Storage;
+ raw_string_ostream OS(Storage);
+ OS << StringRef("hello");
+ EXPECT_EQ("hello", OS.str());
}
} // end anonymous namespace