• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "core/fxcrt/xml/cfx_xmlchardata.h"
6 #include "core/fxcrt/xml/cfx_xmldocument.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/string_write_stream.h"
9 
TEST(CFX_XMLCharDataTest,GetType)10 TEST(CFX_XMLCharDataTest, GetType) {
11   CFX_XMLCharData data(L"My Data");
12   EXPECT_EQ(CFX_XMLNode::Type::kCharData, data.GetType());
13 }
14 
TEST(CFX_XMLCharDataTest,GetText)15 TEST(CFX_XMLCharDataTest, GetText) {
16   CFX_XMLCharData data(L"My Data");
17   EXPECT_EQ(L"My Data", data.GetText());
18 }
19 
TEST(CFX_XMLCharDataTest,Clone)20 TEST(CFX_XMLCharDataTest, Clone) {
21   CFX_XMLDocument doc;
22 
23   CFX_XMLCharData data(L"My Data");
24   CFX_XMLNode* clone = data.Clone(&doc);
25   EXPECT_TRUE(clone != nullptr);
26   EXPECT_NE(&data, clone);
27   ASSERT_EQ(CFX_XMLNode::Type::kCharData, clone->GetType());
28   EXPECT_EQ(L"My Data", ToXMLCharData(clone)->GetText());
29 }
30 
TEST(CFX_XMLCharDataTest,Save)31 TEST(CFX_XMLCharDataTest, Save) {
32   auto stream = pdfium::MakeRetain<StringWriteStream>();
33   CFX_XMLCharData data(L"My Data");
34   data.Save(stream);
35   EXPECT_EQ("<![CDATA[My Data]]>", stream->ToString());
36 }
37