OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/xml_element_writer.h" | 5 #include "tools/gn/xml_element_writer.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 TEST(XmlElementWriter, StartContent) { | 79 TEST(XmlElementWriter, StartContent) { |
80 std::ostringstream out; | 80 std::ostringstream out; |
81 { | 81 { |
82 XmlElementWriter writer(out, "foo", XmlAttributes("bar", "baz")); | 82 XmlElementWriter writer(out, "foo", XmlAttributes("bar", "baz")); |
83 writer.StartContent(false) << "Hello world!"; | 83 writer.StartContent(false) << "Hello world!"; |
84 } | 84 } |
85 EXPECT_EQ("<foo bar=\"baz\">Hello world!</foo>\n", out.str()); | 85 EXPECT_EQ("<foo bar=\"baz\">Hello world!</foo>\n", out.str()); |
86 } | 86 } |
| 87 |
| 88 TEST(XmlElementWriter, TestXmlEscape) { |
| 89 std::string input = "\r \n \t & < > \""; |
| 90 std::string output = XmlEscape(input); |
| 91 std::string expected = " 	 & < > ""; |
| 92 EXPECT_EQ(expected, output); |
| 93 } |
OLD | NEW |