aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-10-17 20:43:08 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-10-17 20:43:08 +0000
commit522b113a752a8e86932eebdc41ba07e058950e41 (patch)
treee61722259b5b41094b9c3f94d3f496e138590a14 /unittests
parent0a22fb66644c3b28836387917e15091573c068b9 (diff)
Add raw_ostream::write_escaped, for writing escaped strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84355 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/raw_ostream_test.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/unittests/Support/raw_ostream_test.cpp b/unittests/Support/raw_ostream_test.cpp
index bd2e95cbb5..2b797b4366 100644
--- a/unittests/Support/raw_ostream_test.cpp
+++ b/unittests/Support/raw_ostream_test.cpp
@@ -127,4 +127,20 @@ TEST(raw_ostreamTest, TinyBuffer) {
EXPECT_EQ("hello1world", OS.str());
}
+TEST(raw_ostreamTest, WriteEscaped) {
+ std::string Str;
+
+ Str = "";
+ raw_string_ostream(Str).write_escaped("hi");
+ EXPECT_EQ("hi", Str);
+
+ Str = "";
+ raw_string_ostream(Str).write_escaped("\\\t\n\"");
+ EXPECT_EQ("\\\\\\t\\n\\\"", Str);
+
+ Str = "";
+ raw_string_ostream(Str).write_escaped("\1\10\200");
+ EXPECT_EQ("\\001\\010\\200", Str);
+}
+
}