diff options
Diffstat (limited to 'xfa/fde/xml/fde_xml_imp_unittest.cpp')
-rw-r--r-- | xfa/fde/xml/fde_xml_imp_unittest.cpp | 165 |
1 files changed, 75 insertions, 90 deletions
diff --git a/xfa/fde/xml/fde_xml_imp_unittest.cpp b/xfa/fde/xml/fde_xml_imp_unittest.cpp index 553afffd86..6db1b1905a 100644 --- a/xfa/fde/xml/fde_xml_imp_unittest.cpp +++ b/xfa/fde/xml/fde_xml_imp_unittest.cpp @@ -26,15 +26,14 @@ TEST(CFDE_XMLSyntaxParser, CData) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -84,15 +83,14 @@ TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -131,15 +129,14 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -174,15 +171,14 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -211,15 +207,14 @@ TEST(CFDE_XMLSyntaxParser, IncompleteCData) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -248,15 +243,14 @@ TEST(CFDE_XMLSyntaxParser, UnClosedCData) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -285,15 +279,14 @@ TEST(CFDE_XMLSyntaxParser, EmptyCData) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -332,15 +325,14 @@ TEST(CFDE_XMLSyntaxParser, Comment) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -375,15 +367,14 @@ TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -418,15 +409,14 @@ TEST(CFDE_XMLSyntaxParser, CommentEmpty) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -461,15 +451,14 @@ TEST(CFDE_XMLSyntaxParser, CommentThreeDash) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -496,15 +485,14 @@ TEST(CFDE_XMLSyntaxParser, CommentTwoDash) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -535,15 +523,14 @@ TEST(CFDE_XMLSyntaxParser, Entities) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -575,15 +562,14 @@ TEST(CFDE_XMLSyntaxParser, EntityOverflowHex) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); @@ -615,15 +601,14 @@ TEST(CFDE_XMLSyntaxParser, EntityOverflowDecimal) { // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); - std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); + CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( + reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); CFDE_XMLSyntaxParser parser; - parser.Init(stream.get(), 256); - - CFX_WideString data; - + parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); + + CFX_WideString data; parser.GetTagName(data); EXPECT_EQ(L"script", data); |