OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/libjingle/xmllite/xmlprinter.h" | |
12 | |
13 #include <sstream> | |
14 #include <string> | |
15 | |
16 #include "webrtc/libjingle/xmllite/qname.h" | |
17 #include "webrtc/libjingle/xmllite/xmlelement.h" | |
18 #include "webrtc/libjingle/xmllite/xmlnsstack.h" | |
19 #include "webrtc/base/common.h" | |
20 #include "webrtc/base/gunit.h" | |
21 | |
22 using buzz::QName; | |
23 using buzz::XmlElement; | |
24 using buzz::XmlnsStack; | |
25 using buzz::XmlPrinter; | |
26 | |
27 TEST(XmlPrinterTest, TestBasicPrinting) { | |
28 XmlElement elt(QName("google:test", "first")); | |
29 std::stringstream ss; | |
30 XmlPrinter::PrintXml(&ss, &elt); | |
31 EXPECT_EQ("<test:first xmlns:test=\"google:test\"/>", ss.str()); | |
32 } | |
33 | |
34 TEST(XmlPrinterTest, TestNamespacedPrinting) { | |
35 XmlElement elt(QName("google:test", "first")); | |
36 elt.AddElement(new XmlElement(QName("nested:test", "second"))); | |
37 std::stringstream ss; | |
38 | |
39 XmlnsStack ns_stack; | |
40 ns_stack.AddXmlns("gg", "google:test"); | |
41 ns_stack.AddXmlns("", "nested:test"); | |
42 | |
43 XmlPrinter::PrintXml(&ss, &elt, &ns_stack); | |
44 EXPECT_EQ("<gg:first><second/></gg:first>", ss.str()); | |
45 } | |
OLD | NEW |