summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml/cfx_xmltext_unittest.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-01 17:01:54 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-01 17:01:54 +0000
commit048afc6aba4848d5296affb4335500f960262580 (patch)
tree1cef231f4c264542412b8ad67db4f622f8eea81d /core/fxcrt/xml/cfx_xmltext_unittest.cpp
parentb5902c78075141d9d569a463486d20ccabd78a2d (diff)
downloadpdfium-048afc6aba4848d5296affb4335500f960262580.tar.xz
Fix CFX_XML and add unit tests
This CL fixes several issues in the CFX_XML class and adds unit tests. Change-Id: I05270690de8f3c45dceb866e17ef899ae6d23389 Reviewed-on: https://pdfium-review.googlesource.com/31753 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_xmltext_unittest.cpp')
-rw-r--r--core/fxcrt/xml/cfx_xmltext_unittest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/fxcrt/xml/cfx_xmltext_unittest.cpp b/core/fxcrt/xml/cfx_xmltext_unittest.cpp
new file mode 100644
index 0000000000..ab977e9546
--- /dev/null
+++ b/core/fxcrt/xml/cfx_xmltext_unittest.cpp
@@ -0,0 +1,41 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/fxcrt/xml/cfx_xmltext.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/string_write_stream.h"
+#include "testing/test_support.h"
+
+TEST(CFX_XMLTextTest, GetType) {
+ CFX_XMLText text(L"My Text");
+ EXPECT_EQ(FX_XMLNODE_Text, text.GetType());
+}
+
+TEST(CFX_XMLTextTest, GetText) {
+ CFX_XMLText data(L"My Data");
+ EXPECT_EQ(L"My Data", data.GetText());
+}
+
+TEST(CFX_XMLTextTest, Clone) {
+ CFX_XMLText data(L"My Data");
+ auto clone = data.Clone();
+ EXPECT_TRUE(clone != nullptr);
+ ASSERT_EQ(FX_XMLNODE_Text, clone->GetType());
+ EXPECT_EQ(L"My Data", static_cast<CFX_XMLText*>(clone.get())->GetText());
+}
+
+TEST(CFX_XMLTextTest, Save) {
+ auto stream = pdfium::MakeRetain<StringWriteStream>();
+ CFX_XMLText data(L"My Data & this is < and > and ' and \" stuff.");
+ data.Save(stream);
+ EXPECT_EQ("My Data &amp; this is &lt; and &gt; and &apos; and &quot; stuff.",
+ stream->ToString());
+}
+
+TEST(CFX_XMLTextTest, SetText) {
+ CFX_XMLText data(L"My Data");
+ EXPECT_EQ(L"My Data", data.GetText());
+ data.SetText(L"New Text");
+ EXPECT_EQ(L"New Text", data.GetText());
+}