From 048afc6aba4848d5296affb4335500f960262580 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 1 May 2018 17:01:54 +0000 Subject: 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 Reviewed-by: Ryan Harrison Reviewed-by: Henrique Nakashima --- core/fxcrt/xml/cfx_xmlchardata_unittest.cpp | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 core/fxcrt/xml/cfx_xmlchardata_unittest.cpp (limited to 'core/fxcrt/xml/cfx_xmlchardata_unittest.cpp') diff --git a/core/fxcrt/xml/cfx_xmlchardata_unittest.cpp b/core/fxcrt/xml/cfx_xmlchardata_unittest.cpp new file mode 100644 index 0000000000..0fa48e520f --- /dev/null +++ b/core/fxcrt/xml/cfx_xmlchardata_unittest.cpp @@ -0,0 +1,34 @@ +// 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_xmlchardata.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/string_write_stream.h" +#include "testing/test_support.h" + +TEST(CFX_XMLCharDataTest, GetType) { + CFX_XMLCharData data(L"My Data"); + EXPECT_EQ(FX_XMLNODE_CharData, data.GetType()); +} + +TEST(CFX_XMLCharDataTest, GetText) { + CFX_XMLCharData data(L"My Data"); + EXPECT_EQ(L"My Data", data.GetText()); +} + +TEST(CFX_XMLCharDataTest, Clone) { + CFX_XMLCharData data(L"My Data"); + auto clone = data.Clone(); + EXPECT_TRUE(clone != nullptr); + EXPECT_NE(&data, clone.get()); + ASSERT_EQ(FX_XMLNODE_CharData, clone->GetType()); + EXPECT_EQ(L"My Data", static_cast(clone.get())->GetText()); +} + +TEST(CFX_XMLCharDataTest, Save) { + auto stream = pdfium::MakeRetain(); + CFX_XMLCharData data(L"My Data"); + data.Save(stream); + EXPECT_EQ("", stream->ToString()); +} -- cgit v1.2.3