Support writing a StringRef to a raw_ostream directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76754 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2009-07-22 17:13:20 +00:00
parent 59fec6a532
commit dbe77cfa0b
2 changed files with 20 additions and 7 deletions

View File

@ -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 @@ TEST(StringRefTest, Utilities) {
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