From f351ba03ebf31103c0a6a0c00b1477d39c060139 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 27 Nov 2017 18:28:06 +0000 Subject: Add some helpers for attribute lookup This CL adds helpers to CXFA_Node to convert from strings to attributes and from attributes to their string names. A static_assert was added to make sure the list of attributes is the same size as the attribute data so the checks can be removed. Change-Id: Idebc65021d71f604bcf498e4cf42252af00d802b Reviewed-on: https://pdfium-review.googlesource.com/19270 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_node_unittest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 xfa/fxfa/parser/cxfa_node_unittest.cpp (limited to 'xfa/fxfa/parser/cxfa_node_unittest.cpp') diff --git a/xfa/fxfa/parser/cxfa_node_unittest.cpp b/xfa/fxfa/parser/cxfa_node_unittest.cpp new file mode 100644 index 0000000000..93df084391 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_node_unittest.cpp @@ -0,0 +1,17 @@ +// Copyright 2017 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 "xfa/fxfa/parser/cxfa_node.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/test_support.h" + +TEST(CXFA_NodeTest, NameToAttribute) { + EXPECT_EQ(XFA_Attribute::Unknown, CXFA_Node::NameToAttribute(L"")); + EXPECT_EQ(XFA_Attribute::Unknown, CXFA_Node::NameToAttribute(L"nonesuch")); + EXPECT_EQ(XFA_Attribute::H, CXFA_Node::NameToAttribute(L"h")); + EXPECT_EQ(XFA_Attribute::Short, CXFA_Node::NameToAttribute(L"short")); + EXPECT_EQ(XFA_Attribute::DecipherOnly, + CXFA_Node::NameToAttribute(L"decipherOnly")); +} -- cgit v1.2.3