react-native-nitro-xlsx 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NitroXlsx.podspec +26 -27
- package/Package.swift +31 -10
- package/README.md +21 -9
- package/android/CMakeLists.txt +20 -27
- package/cpp/HybridNitroXlsx.cpp +25 -1
- package/cpp/HybridXlsxCellFormat.cpp +46 -146
- package/cpp/HybridXlsxCellFormat.hpp +9 -41
- package/cpp/HybridXlsxConditionalFormat.cpp +4 -1
- package/cpp/HybridXlsxConditionalFormats.cpp +5 -1
- package/cpp/HybridXlsxWorkbook.cpp +38 -8
- package/cpp/HybridXlsxWorkbook.hpp +10 -1
- package/cpp/HybridXlsxWorksheet.cpp +422 -141
- package/cpp/HybridXlsxWorksheet.hpp +4 -1
- package/cpp/XlsxCacheDir.cpp +25 -2
- package/cpp/XlsxCacheDir.hpp +3 -1
- package/cpp/XlsxCellStyle.hpp +360 -0
- package/cpp/XlsxJson.cpp +29 -8
- package/package.json +2 -2
- package/scripts/run-cpp-tests.sh +1 -1
- package/scripts/sync-openxlsx-headers.sh +34 -0
- package/src/__mocks__/react-native-nitro-modules.ts +523 -20
- package/src/__tests__/index.test.ts +124 -16
- package/src/index.ts +13 -13
- package/thirdparty/OpenXLSX/.clang-format +118 -0
- package/thirdparty/OpenXLSX/.clang-tidy +28 -0
- package/thirdparty/OpenXLSX/.gitignore +130 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_before_XMLNode_wrappers +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_and_stripping +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_char_support +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_support +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespaced_name_disabled +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-08-11-benchmarks_post-XLCellIterator-Rework +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-08-14-benchmarks_post-default-row-column-style-support +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-09-02-benchmarks +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-12-19-benchmarks +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-12-30-benchmarks-post-XLSharedStrings-by-ref +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-01-09-benchmarks-post-conditionalFormatsAndSheetProtection +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-01-10-benchmarks-post-XLCellValue-bugfix +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-01-31-benchmarks-post-XLComments-implementation +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-02-02-benchmarks-post-XLRowIterator-Rework +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-07-20-benchmarks-after-hiding-pugixml-internals +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-08-29-benchmarks-after-code-review-with-libzip +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/Benchmark.cpp +249 -0
- package/thirdparty/OpenXLSX/Benchmarks/CMakeLists.txt +19 -0
- package/thirdparty/OpenXLSX/CMakeLists.txt +466 -0
- package/thirdparty/OpenXLSX/Documentation/CMakeLists.txt +31 -0
- package/thirdparty/OpenXLSX/Documentation/Doxyfile.in +2471 -0
- package/thirdparty/OpenXLSX/Documentation/DoxygenLayout.xml +194 -0
- package/thirdparty/OpenXLSX/Documentation/customdoxygen.css +1355 -0
- package/thirdparty/OpenXLSX/Examples/CMakeLists.txt +103 -0
- package/thirdparty/OpenXLSX/Examples/Demo1.cpp +279 -0
- package/thirdparty/OpenXLSX/Examples/Demo10.cpp +545 -0
- package/thirdparty/OpenXLSX/Examples/Demo1A.cpp +137 -0
- package/thirdparty/OpenXLSX/Examples/Demo2.cpp +65 -0
- package/thirdparty/OpenXLSX/Examples/Demo3.cpp +89 -0
- package/thirdparty/OpenXLSX/Examples/Demo4.cpp +86 -0
- package/thirdparty/OpenXLSX/Examples/Demo5.cpp +77 -0
- package/thirdparty/OpenXLSX/Examples/Demo6.cpp +103 -0
- package/thirdparty/OpenXLSX/Examples/Demo7.cpp +79 -0
- package/thirdparty/OpenXLSX/Examples/Demo8.cpp +117 -0
- package/thirdparty/OpenXLSX/Examples/Demo9.cpp +363 -0
- package/thirdparty/OpenXLSX/Examples/cmake/FindLIBZIP.cmake +61 -0
- package/thirdparty/OpenXLSX/Examples/external/CustomZip/CustomZip.hpp +256 -0
- package/thirdparty/OpenXLSX/LICENSE.md +29 -0
- package/thirdparty/OpenXLSX/Makefile.GNU +530 -0
- package/thirdparty/OpenXLSX/Notes/TBDs.txt +16 -0
- package/thirdparty/OpenXLSX/Notes/confirmed-TBCs.txt +8 -0
- package/thirdparty/OpenXLSX/Notes/styles-missing-support.xml +12 -0
- package/thirdparty/OpenXLSX/Notes/todo-list.txt +108 -0
- package/thirdparty/OpenXLSX/OpenXLSX/CMakeLists.txt +631 -0
- package/thirdparty/OpenXLSX/OpenXLSX/OpenXLSX.hpp +63 -0
- package/thirdparty/OpenXLSX/OpenXLSX/OpenXLSXConfig.cmake +11 -0
- package/thirdparty/OpenXLSX/OpenXLSX/cmake/bundle_static_library.cmake +198 -0
- package/thirdparty/OpenXLSX/OpenXLSX/cmake/patch_pkg_config.cmake +69 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/IZipArchive.hpp +361 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/IZipArchive.hpp +361 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/OpenXLSX-Exports.hpp +12 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCell.hpp +367 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellIterator.hpp +252 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellRange.hpp +223 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellReference.hpp +317 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellValue.hpp +793 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLColor.hpp +232 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLColumn.hpp +159 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCommandQuery.hpp +228 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLComments.hpp +270 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLConstants.hpp +18 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLContentTypes.hpp +264 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLDateTime.hpp +175 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLDocument.hpp +505 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLDrawing.hpp +452 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLException.hpp +161 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLFormula.hpp +375 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLIterator.hpp +40 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLMergeCells.hpp +216 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLProperties.hpp +348 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLRelationships.hpp +348 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLRow.hpp +721 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLRowData.hpp +488 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLSharedStrings.hpp +204 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLSheet.hpp +1640 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLStyles.hpp +2390 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLTables.hpp +132 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLWorkbook.hpp +404 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlData.hpp +283 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlFile.hpp +194 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlParser.hpp +282 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlParserForwardDeclarations.hpp +85 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLZipArchive.hpp +232 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/detail/LibZip.hpp +447 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/detail/OpenXLSXFileSystemTools.hpp +207 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/detail/Zippy.hpp +1375 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX-Exports.hpp +12 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCell.hpp +367 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellIterator.hpp +252 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellRange.hpp +223 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellReference.hpp +317 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellValue.hpp +793 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLColor.hpp +232 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLColumn.hpp +159 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCommandQuery.hpp +228 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLComments.hpp +270 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLConstants.hpp +18 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLContentTypes.hpp +264 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDateTime.hpp +175 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDocument.hpp +505 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDrawing.hpp +452 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLException.hpp +161 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLFormula.hpp +375 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLIterator.hpp +40 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLMergeCells.hpp +216 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLProperties.hpp +348 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRelationships.hpp +348 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRow.hpp +721 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRowData.hpp +488 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLSharedStrings.hpp +204 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLSheet.hpp +1640 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLStyles.hpp +2390 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLTables.hpp +132 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLWorkbook.hpp +404 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlData.hpp +283 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlFile.hpp +194 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlParser.hpp +282 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlParserForwardDeclarations.hpp +85 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLZipArchive.hpp +232 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/LibZip.hpp +447 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/OpenXLSXFileSystemTools.hpp +207 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/Zippy.hpp +1375 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCell.cpp +340 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellIterator.cpp +427 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellRange.cpp +221 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellReference.cpp +408 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellValue.cpp +519 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLColor.cpp +202 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLColumn.cpp +141 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLComments.cpp +637 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLContentTypes.cpp +329 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDateTime.cpp +269 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDocument.cpp +1678 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDrawing.cpp +784 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLFormula.cpp +201 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLMergeCells.cpp +357 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLProperties.cpp +810 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRelationships.cpp +529 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRow.cpp +918 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRowData.cpp +508 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLSharedStrings.cpp +220 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLSheet.cpp +1970 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLStyles.cpp +3014 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLTables.cpp +125 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLWorkbook.cpp +784 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlData.cpp +247 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlFile.cpp +160 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlParser.cpp +261 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLZipArchive.cpp +266 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/utilities/XLUtilities.hpp +478 -0
- package/thirdparty/OpenXLSX/README.md +1279 -0
- package/thirdparty/OpenXLSX/Scripts/cmake-cleanup.sh +102 -0
- package/thirdparty/OpenXLSX/Scripts/compile.sh +23 -0
- package/thirdparty/OpenXLSX/Scripts/demos-cleanup.sh +25 -0
- package/thirdparty/OpenXLSX/Scripts/demos-run-all.sh +60 -0
- package/thirdparty/OpenXLSX/Scripts/guarded-xml-format.sh +47 -0
- package/thirdparty/OpenXLSX/Scripts/make-gnu.sh +11 -0
- package/thirdparty/OpenXLSX/Scripts/uninstall-manifest.sh +48 -0
- package/thirdparty/OpenXLSX/Scripts/xml-format-all.sh +19 -0
- package/thirdparty/OpenXLSX/Scripts/xml-format.sh +38 -0
- package/thirdparty/OpenXLSX/Tests/CMakeLists.txt +37 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch.hpp +17799 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_automake.hpp +68 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_sonarqube.hpp +182 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_tap.hpp +278 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_teamcity.hpp +212 -0
- package/thirdparty/OpenXLSX/Tests/main.cpp +55 -0
- package/thirdparty/OpenXLSX/Tests/testXLCell.cpp +176 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellRange.cpp +180 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellReference.cpp +160 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellValue.cpp +366 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellValueProxy.cpp +255 -0
- package/thirdparty/OpenXLSX/Tests/testXLColor.cpp +75 -0
- package/thirdparty/OpenXLSX/Tests/testXLDateTime.cpp +229 -0
- package/thirdparty/OpenXLSX/Tests/testXLDocument.cpp +197 -0
- package/thirdparty/OpenXLSX/Tests/testXLFormula.cpp +131 -0
- package/thirdparty/OpenXLSX/Tests/testXLRow.cpp +597 -0
- package/thirdparty/OpenXLSX/Tests/testXLSheet.cpp +77 -0
- package/thirdparty/OpenXLSX/Tests/ziptest-with-libs.cpp +88 -0
- package/thirdparty/OpenXLSX/Tests/ziptest.cpp +735 -0
- package/thirdparty/OpenXLSX/cmake/get-git-HEAD-ID.cmake +45 -0
- package/thirdparty/OpenXLSX/cmake/libopenxlsxCPackOptions.cmake.in +20 -0
- package/thirdparty/OpenXLSX/cmake/manage_dependency.cmake +813 -0
- package/thirdparty/OpenXLSX/cmake/recursive_library_type_test.cmake +52 -0
- package/thirdparty/OpenXLSX/gnu-make-crutch/OpenXLSX-Exports-shared.hpp +42 -0
- package/thirdparty/OpenXLSX/gnu-make-crutch/OpenXLSX-Exports-static.hpp +42 -0
- package/thirdparty/OpenXLSX/vcpkg.json +24 -0
- package/thirdparty/README.md +46 -0
- package/thirdparty/miniz/.clang-format +47 -0
- package/thirdparty/miniz/.travis.yml +2 -0
- package/thirdparty/miniz/CMakeLists.txt +333 -0
- package/thirdparty/miniz/CMakePresets.json +31 -0
- package/thirdparty/miniz/ChangeLog.md +272 -0
- package/thirdparty/miniz/Config.cmake.in +1 -0
- package/thirdparty/miniz/LICENSE +22 -0
- package/thirdparty/miniz/amalgamate.sh +57 -0
- package/thirdparty/miniz/examples/example1.c +105 -0
- package/thirdparty/miniz/examples/example2.c +164 -0
- package/thirdparty/miniz/examples/example3.c +269 -0
- package/thirdparty/miniz/examples/example4.c +102 -0
- package/thirdparty/miniz/examples/example5.c +327 -0
- package/thirdparty/miniz/examples/example6.c +189 -0
- package/thirdparty/miniz/meson.build +21 -0
- package/thirdparty/miniz/miniz.c +646 -0
- package/thirdparty/miniz/miniz.h +615 -0
- package/thirdparty/miniz/miniz.pc.in +13 -0
- package/thirdparty/miniz/miniz_common.h +89 -0
- package/thirdparty/miniz/miniz_export.h +20 -0
- package/thirdparty/miniz/miniz_tdef.c +1602 -0
- package/thirdparty/miniz/miniz_tdef.h +199 -0
- package/thirdparty/miniz/miniz_tinfl.c +778 -0
- package/thirdparty/miniz/miniz_tinfl.h +150 -0
- package/thirdparty/miniz/miniz_zip.c +4895 -0
- package/thirdparty/miniz/miniz_zip.h +454 -0
- package/thirdparty/miniz/readme.md +46 -0
- package/thirdparty/miniz/test.sh +36 -0
- package/thirdparty/miniz/tests/add_in_place_fuzzer.c +87 -0
- package/thirdparty/miniz/tests/catch_amalgamated.cpp +10795 -0
- package/thirdparty/miniz/tests/catch_amalgamated.hpp +13143 -0
- package/thirdparty/miniz/tests/checksum_fuzzer.c +26 -0
- package/thirdparty/miniz/tests/compress_fuzzer.c +91 -0
- package/thirdparty/miniz/tests/flush_fuzzer.c +88 -0
- package/thirdparty/miniz/tests/fuzz_main.c +55 -0
- package/thirdparty/miniz/tests/large_fuzzer.c +133 -0
- package/thirdparty/miniz/tests/main.cpp +185 -0
- package/thirdparty/miniz/tests/miniz_tdefl_fuzzer.cc +115 -0
- package/thirdparty/miniz/tests/miniz_tester.cpp +1881 -0
- package/thirdparty/miniz/tests/miniz_zip_validate_fuzzer.cc +71 -0
- package/thirdparty/miniz/tests/miniz_zip_writer_fuzzer.cc +96 -0
- package/thirdparty/miniz/tests/ossfuzz.sh +48 -0
- package/thirdparty/miniz/tests/small_fuzzer.c +126 -0
- package/thirdparty/miniz/tests/timer.cpp +152 -0
- package/thirdparty/miniz/tests/timer.h +40 -0
- package/thirdparty/miniz/tests/uncompress2_fuzzer.c +21 -0
- package/thirdparty/miniz/tests/uncompress_fuzzer.c +30 -0
- package/thirdparty/miniz/tests/zip.dict +9 -0
- package/thirdparty/miniz/tests/zip_fuzzer.c +63 -0
- package/thirdparty/pugixml/.codecov.yml +7 -0
- package/thirdparty/pugixml/.gitattributes +1 -0
- package/thirdparty/pugixml/CMakeLists.txt +330 -0
- package/thirdparty/pugixml/LICENSE.md +24 -0
- package/thirdparty/pugixml/Makefile +98 -0
- package/thirdparty/pugixml/README.md +81 -0
- package/thirdparty/pugixml/SECURITY.md +9 -0
- package/thirdparty/pugixml/appveyor.yml +50 -0
- package/thirdparty/pugixml/docs/config.adoc +7 -0
- package/thirdparty/pugixml/docs/images/dom_tree.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_link1.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_link2.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch1.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch2.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch3.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch4.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2010_link1.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2010_link2.png +0 -0
- package/thirdparty/pugixml/docs/manual.adoc +3326 -0
- package/thirdparty/pugixml/docs/manual.html +6395 -0
- package/thirdparty/pugixml/docs/quickstart.adoc +287 -0
- package/thirdparty/pugixml/docs/quickstart.html +1107 -0
- package/thirdparty/pugixml/docs/samples/character.xml +8 -0
- package/thirdparty/pugixml/docs/samples/custom_memory_management.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/include.cpp +64 -0
- package/thirdparty/pugixml/docs/samples/load_error_handling.cpp +33 -0
- package/thirdparty/pugixml/docs/samples/load_file.cpp +16 -0
- package/thirdparty/pugixml/docs/samples/load_memory.cpp +66 -0
- package/thirdparty/pugixml/docs/samples/load_options.cpp +30 -0
- package/thirdparty/pugixml/docs/samples/load_stream.cpp +97 -0
- package/thirdparty/pugixml/docs/samples/modify_add.cpp +29 -0
- package/thirdparty/pugixml/docs/samples/modify_base.cpp +43 -0
- package/thirdparty/pugixml/docs/samples/modify_remove.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/save_custom_writer.cpp +116 -0
- package/thirdparty/pugixml/docs/samples/save_declaration.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/save_file.cpp +17 -0
- package/thirdparty/pugixml/docs/samples/save_options.cpp +48 -0
- package/thirdparty/pugixml/docs/samples/save_stream.cpp +18 -0
- package/thirdparty/pugixml/docs/samples/save_subtree.cpp +26 -0
- package/thirdparty/pugixml/docs/samples/text.cpp +35 -0
- package/thirdparty/pugixml/docs/samples/transitions.xml +7 -0
- package/thirdparty/pugixml/docs/samples/traverse_base.cpp +51 -0
- package/thirdparty/pugixml/docs/samples/traverse_iter.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/traverse_predicate.cpp +48 -0
- package/thirdparty/pugixml/docs/samples/traverse_rangefor.cpp +32 -0
- package/thirdparty/pugixml/docs/samples/traverse_walker.cpp +35 -0
- package/thirdparty/pugixml/docs/samples/tree.xml +12 -0
- package/thirdparty/pugixml/docs/samples/weekly-shift_jis.xml +78 -0
- package/thirdparty/pugixml/docs/samples/weekly-utf-16.xml +0 -0
- package/thirdparty/pugixml/docs/samples/weekly-utf-8.xml +78 -0
- package/thirdparty/pugixml/docs/samples/xgconsole.xml +12 -0
- package/thirdparty/pugixml/docs/samples/xpath_error.cpp +43 -0
- package/thirdparty/pugixml/docs/samples/xpath_query.cpp +36 -0
- package/thirdparty/pugixml/docs/samples/xpath_select.cpp +28 -0
- package/thirdparty/pugixml/docs/samples/xpath_variables.cpp +38 -0
- package/thirdparty/pugixml/readme.txt +50 -0
- package/thirdparty/pugixml/scripts/archive.py +54 -0
- package/thirdparty/pugixml/scripts/cocoapods_push.sh +4 -0
- package/thirdparty/pugixml/scripts/natvis/pugixml.natvis +77 -0
- package/thirdparty/pugixml/scripts/natvis/pugixml_compact.natvis +506 -0
- package/thirdparty/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml +17 -0
- package/thirdparty/pugixml/scripts/nuget/build/native/pugixml.targets +28 -0
- package/thirdparty/pugixml/scripts/nuget/pugixml.nuspec +20 -0
- package/thirdparty/pugixml/scripts/nuget_build.ps1 +60 -0
- package/thirdparty/pugixml/scripts/premake4.lua +92 -0
- package/thirdparty/pugixml/scripts/pugixml-config.cmake.in +12 -0
- package/thirdparty/pugixml/scripts/pugixml.pc.in +11 -0
- package/thirdparty/pugixml/scripts/pugixml.podspec +14 -0
- package/thirdparty/pugixml/scripts/pugixml.xcodeproj/project.pbxproj +212 -0
- package/thirdparty/pugixml/scripts/pugixml_airplay.mkf +13 -0
- package/thirdparty/pugixml/scripts/pugixml_codeblocks.cbp +44 -0
- package/thirdparty/pugixml/scripts/pugixml_codelite.project +56 -0
- package/thirdparty/pugixml/scripts/pugixml_dll.rc +45 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2005.vcproj +343 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2005_static.vcproj +343 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2008.vcproj +339 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2008_static.vcproj +339 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2010.vcxproj +191 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2010_static.vcxproj +191 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2013.vcxproj +199 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2013_static.vcxproj +199 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2015.vcxproj +172 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2015_static.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2017.vcxproj +172 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2017_static.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2019.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2019_static.vcxproj +180 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2022.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2022_static.vcxproj +180 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2026.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2026_static.vcxproj +180 -0
- package/thirdparty/pugixml/scripts/sbom.cdx.json +47 -0
- package/thirdparty/pugixml/src/pugiconfig.hpp +81 -0
- package/thirdparty/pugixml/src/pugixml.cpp +13776 -0
- package/thirdparty/pugixml/src/pugixml.hpp +1604 -0
- package/thirdparty/pugixml/tests/allocator.cpp +175 -0
- package/thirdparty/pugixml/tests/allocator.hpp +10 -0
- package/thirdparty/pugixml/tests/autotest-appveyor.ps1 +93 -0
- package/thirdparty/pugixml/tests/cmake-appveyor.ps1 +57 -0
- package/thirdparty/pugixml/tests/data/empty.xml +0 -0
- package/thirdparty/pugixml/tests/data/large.xml +1 -0
- package/thirdparty/pugixml/tests/data/latintest_latin1.xml +1 -0
- package/thirdparty/pugixml/tests/data/latintest_utf8.xml +1 -0
- package/thirdparty/pugixml/tests/data/multiline.xml +3 -0
- package/thirdparty/pugixml/tests/data/small.xml +1 -0
- package/thirdparty/pugixml/tests/data/truncation.xml +19 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8.xml +87 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8_bom.xml +87 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8_clean.xml +84 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8_nodecl.xml +86 -0
- package/thirdparty/pugixml/tests/data//321/202/320/265/321/201/321/202.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/basic.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/doctype.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/refs.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/types.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/utf16.xml +0 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/utf32.xml +0 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/basic.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/functions.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/math.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/path.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/predicate.xpath +1 -0
- package/thirdparty/pugixml/tests/fuzz_parse.cpp +14 -0
- package/thirdparty/pugixml/tests/fuzz_parse.dict +72 -0
- package/thirdparty/pugixml/tests/fuzz_setup.sh +11 -0
- package/thirdparty/pugixml/tests/fuzz_xpath.cpp +46 -0
- package/thirdparty/pugixml/tests/fuzz_xpath.dict +72 -0
- package/thirdparty/pugixml/tests/helpers.hpp +114 -0
- package/thirdparty/pugixml/tests/main.cpp +218 -0
- package/thirdparty/pugixml/tests/test.cpp +220 -0
- package/thirdparty/pugixml/tests/test.hpp +175 -0
- package/thirdparty/pugixml/tests/test_compact.cpp +150 -0
- package/thirdparty/pugixml/tests/test_deprecated.cpp +25 -0
- package/thirdparty/pugixml/tests/test_document.cpp +1910 -0
- package/thirdparty/pugixml/tests/test_dom_modify.cpp +2122 -0
- package/thirdparty/pugixml/tests/test_dom_text.cpp +601 -0
- package/thirdparty/pugixml/tests/test_dom_traverse.cpp +1481 -0
- package/thirdparty/pugixml/tests/test_header_guard.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iosfwd_1.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iosfwd_2.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iostream_1.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iostream_2.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_only_1.cpp +21 -0
- package/thirdparty/pugixml/tests/test_header_only_2.cpp +21 -0
- package/thirdparty/pugixml/tests/test_header_string_1.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_string_2.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_string_iostream.cpp +5 -0
- package/thirdparty/pugixml/tests/test_memory.cpp +303 -0
- package/thirdparty/pugixml/tests/test_parse.cpp +1463 -0
- package/thirdparty/pugixml/tests/test_parse_doctype.cpp +366 -0
- package/thirdparty/pugixml/tests/test_unicode.cpp +152 -0
- package/thirdparty/pugixml/tests/test_version.cpp +5 -0
- package/thirdparty/pugixml/tests/test_write.cpp +757 -0
- package/thirdparty/pugixml/tests/test_xpath.cpp +833 -0
- package/thirdparty/pugixml/tests/test_xpath_api.cpp +646 -0
- package/thirdparty/pugixml/tests/test_xpath_functions.cpp +844 -0
- package/thirdparty/pugixml/tests/test_xpath_operators.cpp +566 -0
- package/thirdparty/pugixml/tests/test_xpath_parse.cpp +428 -0
- package/thirdparty/pugixml/tests/test_xpath_paths.cpp +787 -0
- package/thirdparty/pugixml/tests/test_xpath_paths_abbrev_w3c.cpp +219 -0
- package/thirdparty/pugixml/tests/test_xpath_paths_w3c.cpp +312 -0
- package/thirdparty/pugixml/tests/test_xpath_variables.cpp +683 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_1.cpp +411 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_2.cpp +417 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_3.cpp +321 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_4.cpp +300 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_5.cpp +295 -0
- package/thirdparty/pugixml/tests/writer_string.cpp +79 -0
- package/thirdparty/pugixml/tests/writer_string.hpp +27 -0
- package/scripts/prepare-openxlsx.js +0 -126
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
#include "test.hpp"
|
|
2
|
+
|
|
3
|
+
#include "writer_string.hpp"
|
|
4
|
+
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <sstream>
|
|
7
|
+
#include <stdexcept>
|
|
8
|
+
|
|
9
|
+
using namespace pugi;
|
|
10
|
+
|
|
11
|
+
TEST_XML(write_simple, "<node attr='1'><child>text</child></node>")
|
|
12
|
+
{
|
|
13
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\n<child>text</child>\n</node>\n"), STR(""), 0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
TEST_XML(write_raw, "<node attr='1'><child>text</child></node>")
|
|
17
|
+
{
|
|
18
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\"><child>text</child></node>"), STR(""), format_raw);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
TEST_XML(write_indent, "<node attr='1'><child><sub>text</sub></child></node>")
|
|
22
|
+
{
|
|
23
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\n\t<child>\n\t\t<sub>text</sub>\n\t</child>\n</node>\n"), STR("\t"), format_indent);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
TEST_XML(write_indent_attributes, "<node attr='1' other='2'><child><sub>text</sub></child></node>")
|
|
27
|
+
{
|
|
28
|
+
CHECK_NODE_EX(doc, STR("<node\n\tattr=\"1\"\n\tother=\"2\">\n\t<child>\n\t\t<sub>text</sub>\n\t</child>\n</node>\n"), STR("\t"), format_indent_attributes);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
TEST_XML(write_indent_attributes_empty_element, "<node attr='1' other='2' />")
|
|
32
|
+
{
|
|
33
|
+
CHECK_NODE_EX(doc, STR("<node\n\tattr=\"1\"\n\tother=\"2\" />\n"), STR("\t"), format_indent_attributes);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
TEST_XML_FLAGS(write_indent_attributes_declaration, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><node attr='1' other='2' />", parse_full)
|
|
37
|
+
{
|
|
38
|
+
CHECK_NODE_EX(doc, STR("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<node\n\tattr=\"1\"\n\tother=\"2\" />\n"), STR("\t"), format_indent_attributes);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
TEST_XML(write_indent_attributes_raw, "<node attr='1' other='2'><child><sub>text</sub></child></node>")
|
|
42
|
+
{
|
|
43
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\" other=\"2\"><child><sub>text</sub></child></node>"), STR("\t"), format_indent_attributes | format_raw);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
TEST_XML(write_indent_attributes_empty_indent, "<node attr='1' other='2'><child><sub>text</sub></child></node>")
|
|
47
|
+
{
|
|
48
|
+
CHECK_NODE_EX(doc, STR("<node\nattr=\"1\"\nother=\"2\">\n<child>\n<sub>text</sub>\n</child>\n</node>\n"), STR(""), format_indent_attributes);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
TEST_XML(write_pcdata, "<node attr='1'><child><sub/>text</child></node>")
|
|
52
|
+
{
|
|
53
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\n\t<child>\n\t\t<sub />text</child>\n</node>\n"), STR("\t"), format_indent);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
TEST_XML_FLAGS(write_cdata, "<![CDATA[value]]>", parse_cdata | parse_fragment)
|
|
57
|
+
{
|
|
58
|
+
CHECK_NODE(doc, STR("<![CDATA[value]]>"));
|
|
59
|
+
CHECK_NODE_EX(doc, STR("<![CDATA[value]]>"), STR(""), 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
TEST_XML_FLAGS(write_cdata_empty, "<![CDATA[]]>", parse_cdata | parse_fragment)
|
|
63
|
+
{
|
|
64
|
+
CHECK_NODE(doc, STR("<![CDATA[]]>"));
|
|
65
|
+
CHECK_NODE_EX(doc, STR("<![CDATA[]]>"), STR(""), 0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
TEST_XML_FLAGS(write_cdata_escape, "<![CDATA[value]]>", parse_cdata | parse_fragment)
|
|
69
|
+
{
|
|
70
|
+
CHECK_NODE(doc, STR("<![CDATA[value]]>"));
|
|
71
|
+
|
|
72
|
+
doc.first_child().set_value(STR("1]]>2]]>3"));
|
|
73
|
+
CHECK_NODE(doc, STR("<![CDATA[1]]]]><![CDATA[>2]]]]><![CDATA[>3]]>"));
|
|
74
|
+
|
|
75
|
+
doc.first_child().set_value(STR("1]"));
|
|
76
|
+
CHECK_NODE(doc, STR("<![CDATA[1]]]>"));
|
|
77
|
+
|
|
78
|
+
doc.first_child().set_value(STR("1]]"));
|
|
79
|
+
CHECK_NODE(doc, STR("<![CDATA[1]]]]>"));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
TEST_XML(write_cdata_inner, "<node><![CDATA[value]]></node>")
|
|
83
|
+
{
|
|
84
|
+
CHECK_NODE(doc, STR("<node><![CDATA[value]]></node>"));
|
|
85
|
+
CHECK_NODE_EX(doc, STR("<node><![CDATA[value]]></node>\n"), STR(""), 0);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
TEST(write_cdata_null)
|
|
89
|
+
{
|
|
90
|
+
xml_document doc;
|
|
91
|
+
doc.append_child(node_cdata);
|
|
92
|
+
doc.append_child(STR("node")).append_child(node_cdata);
|
|
93
|
+
|
|
94
|
+
CHECK_NODE(doc, STR("<![CDATA[]]><node><![CDATA[]]></node>"));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
TEST_XML_FLAGS(write_comment, "<!--text-->", parse_comments | parse_fragment)
|
|
98
|
+
{
|
|
99
|
+
CHECK_NODE(doc, STR("<!--text-->"));
|
|
100
|
+
CHECK_NODE_EX(doc, STR("<!--text-->\n"), STR(""), 0);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
TEST(write_comment_invalid)
|
|
104
|
+
{
|
|
105
|
+
xml_document doc;
|
|
106
|
+
xml_node child = doc.append_child(node_comment);
|
|
107
|
+
|
|
108
|
+
CHECK_NODE(doc, STR("<!---->"));
|
|
109
|
+
|
|
110
|
+
child.set_value(STR("-"));
|
|
111
|
+
CHECK_NODE(doc, STR("<!--- -->"));
|
|
112
|
+
|
|
113
|
+
child.set_value(STR("--"));
|
|
114
|
+
CHECK_NODE(doc, STR("<!--- - -->"));
|
|
115
|
+
|
|
116
|
+
child.set_value(STR("---"));
|
|
117
|
+
CHECK_NODE(doc, STR("<!--- - - -->"));
|
|
118
|
+
|
|
119
|
+
child.set_value(STR("-->"));
|
|
120
|
+
CHECK_NODE(doc, STR("<!--- ->-->"));
|
|
121
|
+
|
|
122
|
+
child.set_value(STR("-->-"));
|
|
123
|
+
CHECK_NODE(doc, STR("<!--- ->- -->"));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
TEST(write_comment_null)
|
|
127
|
+
{
|
|
128
|
+
xml_document doc;
|
|
129
|
+
doc.append_child(node_comment);
|
|
130
|
+
|
|
131
|
+
CHECK_NODE(doc, STR("<!---->"));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
TEST_XML_FLAGS(write_pi, "<?name value?>", parse_pi | parse_fragment)
|
|
135
|
+
{
|
|
136
|
+
CHECK_NODE(doc, STR("<?name value?>"));
|
|
137
|
+
CHECK_NODE_EX(doc, STR("<?name value?>\n"), STR(""), 0);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
TEST(write_pi_null)
|
|
141
|
+
{
|
|
142
|
+
xml_document doc;
|
|
143
|
+
xml_node node = doc.append_child(node_pi);
|
|
144
|
+
|
|
145
|
+
CHECK_NODE(doc, STR("<?:anonymous?>"));
|
|
146
|
+
|
|
147
|
+
node.set_value(STR("value"));
|
|
148
|
+
|
|
149
|
+
CHECK_NODE(doc, STR("<?:anonymous value?>"));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
TEST(write_pi_invalid)
|
|
153
|
+
{
|
|
154
|
+
xml_document doc;
|
|
155
|
+
xml_node node = doc.append_child(node_pi);
|
|
156
|
+
|
|
157
|
+
node.set_name(STR("test"));
|
|
158
|
+
node.set_value(STR("?"));
|
|
159
|
+
|
|
160
|
+
CHECK_NODE(doc, STR("<?test ?") STR("?>"));
|
|
161
|
+
|
|
162
|
+
node.set_value(STR("?>"));
|
|
163
|
+
|
|
164
|
+
CHECK_NODE(doc, STR("<?test ? >?>"));
|
|
165
|
+
|
|
166
|
+
node.set_value(STR("<?foo?>"));
|
|
167
|
+
|
|
168
|
+
CHECK_NODE(doc, STR("<?test <?foo? >?>"));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
TEST_XML_FLAGS(write_declaration, "<?xml version='2.0'?>", parse_declaration | parse_fragment)
|
|
172
|
+
{
|
|
173
|
+
CHECK_NODE(doc, STR("<?xml version=\"2.0\"?>"));
|
|
174
|
+
CHECK_NODE_EX(doc, STR("<?xml version=\"2.0\"?>\n"), STR(""), 0);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
TEST_XML_FLAGS(write_doctype, "<!DOCTYPE id [ foo ]>", parse_doctype | parse_fragment)
|
|
178
|
+
{
|
|
179
|
+
CHECK_NODE(doc, STR("<!DOCTYPE id [ foo ]>"));
|
|
180
|
+
CHECK_NODE_EX(doc, STR("<!DOCTYPE id [ foo ]>\n"), STR(""), 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
TEST(write_doctype_null)
|
|
184
|
+
{
|
|
185
|
+
xml_document doc;
|
|
186
|
+
doc.append_child(node_doctype);
|
|
187
|
+
|
|
188
|
+
CHECK_NODE(doc, STR("<!DOCTYPE>"));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
TEST_XML(write_escape, "<node attr=''>text</node>")
|
|
192
|
+
{
|
|
193
|
+
doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t");
|
|
194
|
+
doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t"));
|
|
195
|
+
|
|
196
|
+
CHECK_NODE(doc, STR("<node attr=\"<>'"& 	\"><>'\"&\r\n\t</node>"));
|
|
197
|
+
CHECK_NODE_EX(doc, STR("<node attr='<>'\"& 	'><>'\"&\r\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
TEST_XML(write_escape_roundtrip, "<node attr=''>text</node>")
|
|
201
|
+
{
|
|
202
|
+
doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t");
|
|
203
|
+
doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t"));
|
|
204
|
+
|
|
205
|
+
std::string contents = write_narrow(doc, format_raw, encoding_utf8);
|
|
206
|
+
|
|
207
|
+
CHECK(doc.load_buffer(contents.c_str(), contents.size()));
|
|
208
|
+
|
|
209
|
+
// Note: this string is almost identical to the string from write_escape with the exception of \r
|
|
210
|
+
// \r in PCDATA doesn't roundtrip because it has to go through newline conversion (which could be disabled, but is active by default)
|
|
211
|
+
CHECK_NODE(doc, STR("<node attr=\"<>'"& 	\"><>'\"&\n\t</node>"));
|
|
212
|
+
CHECK_NODE_EX(doc, STR("<node attr='<>'\"& 	'><>'\"&\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
TEST_XML(write_escape_unicode, "<node attr='㰀'/>")
|
|
216
|
+
{
|
|
217
|
+
#ifdef PUGIXML_WCHAR_MODE
|
|
218
|
+
#ifdef U_LITERALS
|
|
219
|
+
CHECK_NODE(doc, STR("<node attr=\"\u3c00\"/>"));
|
|
220
|
+
#else
|
|
221
|
+
CHECK_NODE(doc, STR("<node attr=\"\x3c00\"/>"));
|
|
222
|
+
#endif
|
|
223
|
+
#else
|
|
224
|
+
CHECK_NODE(doc, STR("<node attr=\"\xe3\xb0\x80\"/>"));
|
|
225
|
+
#endif
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
TEST_XML(write_no_escapes, "<node attr=''>text</node>")
|
|
229
|
+
{
|
|
230
|
+
doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t");
|
|
231
|
+
doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t"));
|
|
232
|
+
|
|
233
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"<>'\"&\x04\r\n\t\"><>'\"&\x04\r\n\t</node>"), STR(""), format_raw | format_no_escapes);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
struct test_writer: xml_writer
|
|
237
|
+
{
|
|
238
|
+
std::basic_string<char_t> contents;
|
|
239
|
+
|
|
240
|
+
void write(const void* data, size_t size) PUGIXML_OVERRIDE
|
|
241
|
+
{
|
|
242
|
+
CHECK(size % sizeof(char_t) == 0);
|
|
243
|
+
contents.append(static_cast<const char_t*>(data), size / sizeof(char_t));
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
TEST_XML(write_print_writer, "<node/>")
|
|
248
|
+
{
|
|
249
|
+
test_writer writer;
|
|
250
|
+
doc.print(writer, STR(""), format_default, get_native_encoding());
|
|
251
|
+
|
|
252
|
+
CHECK(writer.contents == STR("<node />\n"));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
#ifndef PUGIXML_NO_STL
|
|
256
|
+
TEST_XML(write_print_stream, "<node/>")
|
|
257
|
+
{
|
|
258
|
+
std::ostringstream oss;
|
|
259
|
+
doc.print(oss, STR(""), format_default, encoding_utf8);
|
|
260
|
+
|
|
261
|
+
CHECK(oss.str() == "<node />\n");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
TEST_XML(write_print_stream_encode, "<n/>")
|
|
265
|
+
{
|
|
266
|
+
std::ostringstream oss;
|
|
267
|
+
doc.print(oss, STR(""), format_default, encoding_utf16_be);
|
|
268
|
+
|
|
269
|
+
CHECK(oss.str() == std::string("\x00<\x00n\x00 \x00/\x00>\x00\n", 12));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
TEST_XML(write_print_stream_wide, "<node/>")
|
|
273
|
+
{
|
|
274
|
+
std::basic_ostringstream<wchar_t> oss;
|
|
275
|
+
doc.print(oss, STR(""), format_default, encoding_utf8);
|
|
276
|
+
|
|
277
|
+
CHECK(oss.str() == L"<node />\n");
|
|
278
|
+
}
|
|
279
|
+
#endif
|
|
280
|
+
|
|
281
|
+
TEST_XML(write_huge_chunk, "<node/>")
|
|
282
|
+
{
|
|
283
|
+
std::basic_string<char_t> name(10000, STR('n'));
|
|
284
|
+
doc.child(STR("node")).set_name(name.c_str());
|
|
285
|
+
|
|
286
|
+
test_writer writer;
|
|
287
|
+
doc.print(writer, STR(""), format_default, get_native_encoding());
|
|
288
|
+
|
|
289
|
+
CHECK(writer.contents == STR("<") + name + STR(" />\n"));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
TEST(write_encodings)
|
|
293
|
+
{
|
|
294
|
+
static char s_utf8[] = "<\x54\xC2\xA2\xE2\x82\xAC\xF0\xA4\xAD\xA2/>";
|
|
295
|
+
|
|
296
|
+
xml_document doc;
|
|
297
|
+
CHECK(doc.load_buffer(s_utf8, sizeof(s_utf8), parse_default, encoding_utf8));
|
|
298
|
+
|
|
299
|
+
CHECK(write_narrow(doc, format_default, encoding_utf8) == "<\x54\xC2\xA2\xE2\x82\xAC\xF0\xA4\xAD\xA2 />\n");
|
|
300
|
+
|
|
301
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf32_le, "<\x00\x00\x00\x54\x00\x00\x00\xA2\x00\x00\x00\xAC\x20\x00\x00\x62\x4B\x02\x00 \x00\x00\x00/\x00\x00\x00>\x00\x00\x00\n\x00\x00\x00", 36));
|
|
302
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf32_be, "\x00\x00\x00<\x00\x00\x00\x54\x00\x00\x00\xA2\x00\x00\x20\xAC\x00\x02\x4B\x62\x00\x00\x00 \x00\x00\x00/\x00\x00\x00>\x00\x00\x00\n", 36));
|
|
303
|
+
CHECK(write_narrow(doc, format_default, encoding_utf32) == write_narrow(doc, format_default, is_little_endian() ? encoding_utf32_le : encoding_utf32_be));
|
|
304
|
+
|
|
305
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf16_le, "<\x00\x54\x00\xA2\x00\xAC\x20\x52\xd8\x62\xdf \x00/\x00>\x00\n\x00", 20));
|
|
306
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf16_be, "\x00<\x00\x54\x00\xA2\x20\xAC\xd8\x52\xdf\x62\x00 \x00/\x00>\x00\n", 20));
|
|
307
|
+
CHECK(write_narrow(doc, format_default, encoding_utf16) == write_narrow(doc, format_default, is_little_endian() ? encoding_utf16_le : encoding_utf16_be));
|
|
308
|
+
|
|
309
|
+
size_t wcharsize = sizeof(wchar_t);
|
|
310
|
+
std::basic_string<wchar_t> v = write_wide(doc, format_default, encoding_wchar);
|
|
311
|
+
|
|
312
|
+
if (wcharsize == 4)
|
|
313
|
+
{
|
|
314
|
+
CHECK(v.size() == 9 && v[0] == '<' && v[1] == 0x54 && v[2] == 0xA2 && v[3] == 0x20AC && v[4] == wchar_cast(0x24B62) && v[5] == ' ' && v[6] == '/' && v[7] == '>' && v[8] == '\n');
|
|
315
|
+
}
|
|
316
|
+
else
|
|
317
|
+
{
|
|
318
|
+
CHECK(v.size() == 10 && v[0] == '<' && v[1] == 0x54 && v[2] == 0xA2 && v[3] == 0x20AC && v[4] == wchar_cast(0xd852) && v[5] == wchar_cast(0xdf62) && v[6] == ' ' && v[7] == '/' && v[8] == '>' && v[9] == '\n');
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
CHECK(test_write_narrow(doc, format_default, encoding_latin1, "<\x54\xA2?? />\n", 9));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
#ifdef PUGIXML_WCHAR_MODE
|
|
325
|
+
TEST(write_encoding_huge)
|
|
326
|
+
{
|
|
327
|
+
const unsigned int N = 16000;
|
|
328
|
+
|
|
329
|
+
// make a large utf16 name consisting of 6-byte char pairs (6 does not divide internal buffer size, so will need split correction)
|
|
330
|
+
std::string s_utf16 = std::string("\x00<", 2);
|
|
331
|
+
|
|
332
|
+
for (unsigned int i = 0; i < N; ++i) s_utf16 += "\x20\xAC\xd8\x52\xdf\x62";
|
|
333
|
+
|
|
334
|
+
s_utf16 += std::string("\x00/\x00>", 4);
|
|
335
|
+
|
|
336
|
+
xml_document doc;
|
|
337
|
+
CHECK(doc.load_buffer(&s_utf16[0], s_utf16.length(), parse_default, encoding_utf16_be));
|
|
338
|
+
|
|
339
|
+
std::string s_utf8 = "<";
|
|
340
|
+
|
|
341
|
+
for (unsigned int j = 0; j < N; ++j) s_utf8 += "\xE2\x82\xAC\xF0\xA4\xAD\xA2";
|
|
342
|
+
|
|
343
|
+
s_utf8 += " />\n";
|
|
344
|
+
|
|
345
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf8, s_utf8.c_str(), s_utf8.length()));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
TEST(write_encoding_huge_invalid)
|
|
349
|
+
{
|
|
350
|
+
size_t wcharsize = sizeof(wchar_t);
|
|
351
|
+
|
|
352
|
+
if (wcharsize == 2)
|
|
353
|
+
{
|
|
354
|
+
const unsigned int N = 16000;
|
|
355
|
+
|
|
356
|
+
// make a large utf16 name consisting of leading surrogate chars
|
|
357
|
+
std::basic_string<wchar_t> s_utf16;
|
|
358
|
+
|
|
359
|
+
for (unsigned int i = 0; i < N; ++i) s_utf16 += static_cast<wchar_t>(0xd852);
|
|
360
|
+
|
|
361
|
+
xml_document doc;
|
|
362
|
+
doc.append_child().set_name(s_utf16.c_str());
|
|
363
|
+
|
|
364
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf8, "< />\n", 5));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
#else
|
|
368
|
+
TEST(write_encoding_huge)
|
|
369
|
+
{
|
|
370
|
+
const unsigned int N = 16000;
|
|
371
|
+
|
|
372
|
+
// make a large utf8 name consisting of 3-byte chars (3 does not divide internal buffer size, so will need split correction)
|
|
373
|
+
std::string s_utf8 = "<";
|
|
374
|
+
|
|
375
|
+
for (unsigned int i = 0; i < N; ++i) s_utf8 += "\xE2\x82\xAC";
|
|
376
|
+
|
|
377
|
+
s_utf8 += "/>";
|
|
378
|
+
|
|
379
|
+
xml_document doc;
|
|
380
|
+
CHECK(doc.load_buffer(&s_utf8[0], s_utf8.length(), parse_default, encoding_utf8));
|
|
381
|
+
|
|
382
|
+
std::string s_utf16 = std::string("\x00<", 2);
|
|
383
|
+
|
|
384
|
+
for (unsigned int j = 0; j < N; ++j) s_utf16 += "\x20\xAC";
|
|
385
|
+
|
|
386
|
+
s_utf16 += std::string("\x00 \x00/\x00>\x00\n", 8);
|
|
387
|
+
|
|
388
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf16_be, s_utf16.c_str(), s_utf16.length()));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
TEST(write_encoding_huge_invalid)
|
|
392
|
+
{
|
|
393
|
+
const unsigned int N = 16000;
|
|
394
|
+
|
|
395
|
+
// make a large utf8 name consisting of non-leading chars
|
|
396
|
+
std::string s_utf8;
|
|
397
|
+
|
|
398
|
+
for (unsigned int i = 0; i < N; ++i) s_utf8 += "\x82";
|
|
399
|
+
|
|
400
|
+
xml_document doc;
|
|
401
|
+
doc.append_child().set_name(s_utf8.c_str());
|
|
402
|
+
|
|
403
|
+
std::string s_utf16 = std::string("\x00<\x00 \x00/\x00>\x00\n", 10);
|
|
404
|
+
|
|
405
|
+
CHECK(test_write_narrow(doc, format_default, encoding_utf16_be, s_utf16.c_str(), s_utf16.length()));
|
|
406
|
+
}
|
|
407
|
+
#endif
|
|
408
|
+
|
|
409
|
+
TEST(write_unicode_escape)
|
|
410
|
+
{
|
|
411
|
+
char s_utf8[] = "<\xE2\x82\xAC \xC2\xA2='\"\xF0\xA4\xAD\xA2
\"'>&\x14\xF0\xA4\xAD\xA2<</\xE2\x82\xAC>";
|
|
412
|
+
|
|
413
|
+
xml_document doc;
|
|
414
|
+
CHECK(doc.load_buffer(s_utf8, sizeof(s_utf8), parse_default, encoding_utf8));
|
|
415
|
+
|
|
416
|
+
CHECK(write_narrow(doc, format_default, encoding_utf8) == "<\xE2\x82\xAC \xC2\xA2=\""\xF0\xA4\xAD\xA2 "\">&\xF0\xA4\xAD\xA2<</\xE2\x82\xAC>\n");
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
#ifdef PUGIXML_WCHAR_MODE
|
|
420
|
+
static bool test_write_unicode_invalid(const wchar_t* name, const char* expected)
|
|
421
|
+
{
|
|
422
|
+
xml_document doc;
|
|
423
|
+
doc.append_child(node_pcdata).set_value(name);
|
|
424
|
+
|
|
425
|
+
return write_narrow(doc, format_raw, encoding_utf8) == expected;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
TEST(write_unicode_invalid_utf16)
|
|
429
|
+
{
|
|
430
|
+
size_t wcharsize = sizeof(wchar_t);
|
|
431
|
+
|
|
432
|
+
if (wcharsize == 2)
|
|
433
|
+
{
|
|
434
|
+
// check non-terminated degenerate handling
|
|
435
|
+
#ifdef U_LITERALS
|
|
436
|
+
CHECK(test_write_unicode_invalid(L"a\uda1d", "a"));
|
|
437
|
+
CHECK(test_write_unicode_invalid(L"a\uda1d_", "a_"));
|
|
438
|
+
#else
|
|
439
|
+
CHECK(test_write_unicode_invalid(L"a\xda1d", "a"));
|
|
440
|
+
CHECK(test_write_unicode_invalid(L"a\xda1d_", "a_"));
|
|
441
|
+
#endif
|
|
442
|
+
|
|
443
|
+
// check incorrect leading code
|
|
444
|
+
#ifdef U_LITERALS
|
|
445
|
+
CHECK(test_write_unicode_invalid(L"a\ude24", "a"));
|
|
446
|
+
CHECK(test_write_unicode_invalid(L"a\ude24_", "a_"));
|
|
447
|
+
#else
|
|
448
|
+
CHECK(test_write_unicode_invalid(L"a\xde24", "a"));
|
|
449
|
+
CHECK(test_write_unicode_invalid(L"a\xde24_", "a_"));
|
|
450
|
+
#endif
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
#else
|
|
454
|
+
static bool test_write_unicode_invalid(const char* name, const wchar_t* expected)
|
|
455
|
+
{
|
|
456
|
+
xml_document doc;
|
|
457
|
+
doc.append_child(node_pcdata).set_value(name);
|
|
458
|
+
|
|
459
|
+
return write_wide(doc, format_raw, encoding_wchar) == expected;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
TEST(write_unicode_invalid_utf8)
|
|
463
|
+
{
|
|
464
|
+
// invalid 1-byte input
|
|
465
|
+
CHECK(test_write_unicode_invalid("a\xb0", L"a"));
|
|
466
|
+
CHECK(test_write_unicode_invalid("a\xb0_", L"a_"));
|
|
467
|
+
|
|
468
|
+
// invalid 2-byte input
|
|
469
|
+
CHECK(test_write_unicode_invalid("a\xc0", L"a"));
|
|
470
|
+
CHECK(test_write_unicode_invalid("a\xd0", L"a"));
|
|
471
|
+
CHECK(test_write_unicode_invalid("a\xc0_", L"a_"));
|
|
472
|
+
CHECK(test_write_unicode_invalid("a\xd0_", L"a_"));
|
|
473
|
+
|
|
474
|
+
// invalid 3-byte input
|
|
475
|
+
CHECK(test_write_unicode_invalid("a\xe2\x80", L"a"));
|
|
476
|
+
CHECK(test_write_unicode_invalid("a\xe2", L"a"));
|
|
477
|
+
CHECK(test_write_unicode_invalid("a\xe2\x80_", L"a_"));
|
|
478
|
+
CHECK(test_write_unicode_invalid("a\xe2_", L"a_"));
|
|
479
|
+
|
|
480
|
+
// invalid 4-byte input
|
|
481
|
+
CHECK(test_write_unicode_invalid("a\xf2\x97\x98", L"a"));
|
|
482
|
+
CHECK(test_write_unicode_invalid("a\xf2\x97", L"a"));
|
|
483
|
+
CHECK(test_write_unicode_invalid("a\xf2", L"a"));
|
|
484
|
+
CHECK(test_write_unicode_invalid("a\xf2\x97\x98_", L"a_"));
|
|
485
|
+
CHECK(test_write_unicode_invalid("a\xf2\x97_", L"a_"));
|
|
486
|
+
CHECK(test_write_unicode_invalid("a\xf2_", L"a_"));
|
|
487
|
+
|
|
488
|
+
// invalid 5-byte input
|
|
489
|
+
CHECK(test_write_unicode_invalid("a\xf8_", L"a_"));
|
|
490
|
+
}
|
|
491
|
+
#endif
|
|
492
|
+
|
|
493
|
+
TEST(write_no_name_element)
|
|
494
|
+
{
|
|
495
|
+
xml_document doc;
|
|
496
|
+
xml_node root = doc.append_child();
|
|
497
|
+
root.append_child();
|
|
498
|
+
root.append_child().append_child(node_pcdata).set_value(STR("text"));
|
|
499
|
+
|
|
500
|
+
CHECK_NODE(doc, STR("<:anonymous><:anonymous/><:anonymous>text</:anonymous></:anonymous>"));
|
|
501
|
+
CHECK_NODE_EX(doc, STR("<:anonymous>\n\t<:anonymous />\n\t<:anonymous>text</:anonymous>\n</:anonymous>\n"), STR("\t"), format_default);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
TEST(write_no_name_pi)
|
|
505
|
+
{
|
|
506
|
+
xml_document doc;
|
|
507
|
+
doc.append_child(node_pi);
|
|
508
|
+
|
|
509
|
+
CHECK_NODE(doc, STR("<?:anonymous?>"));
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
TEST(write_no_name_attribute)
|
|
513
|
+
{
|
|
514
|
+
xml_document doc;
|
|
515
|
+
doc.append_child().set_name(STR("root"));
|
|
516
|
+
doc.child(STR("root")).append_attribute(STR(""));
|
|
517
|
+
|
|
518
|
+
CHECK_NODE(doc, STR("<root :anonymous=\"\"/>"));
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
TEST(write_print_empty)
|
|
522
|
+
{
|
|
523
|
+
test_writer writer;
|
|
524
|
+
xml_node().print(writer);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
#ifndef PUGIXML_NO_STL
|
|
528
|
+
TEST(write_print_stream_empty)
|
|
529
|
+
{
|
|
530
|
+
std::ostringstream oss;
|
|
531
|
+
xml_node().print(oss);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
TEST(write_print_stream_empty_wide)
|
|
535
|
+
{
|
|
536
|
+
std::basic_ostringstream<wchar_t> oss;
|
|
537
|
+
xml_node().print(oss);
|
|
538
|
+
}
|
|
539
|
+
#endif
|
|
540
|
+
|
|
541
|
+
TEST(write_stackless)
|
|
542
|
+
{
|
|
543
|
+
unsigned int count = 20000;
|
|
544
|
+
std::basic_string<char_t> data;
|
|
545
|
+
|
|
546
|
+
for (unsigned int i = 0; i < count; ++i)
|
|
547
|
+
data += STR("<a>");
|
|
548
|
+
|
|
549
|
+
data += STR("text");
|
|
550
|
+
|
|
551
|
+
for (unsigned int j = 0; j < count; ++j)
|
|
552
|
+
data += STR("</a>");
|
|
553
|
+
|
|
554
|
+
xml_document doc;
|
|
555
|
+
CHECK(doc.load_string(data.c_str()));
|
|
556
|
+
|
|
557
|
+
CHECK_NODE(doc, data.c_str());
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
TEST_XML(write_indent_custom, "<node attr='1'><child><sub>text</sub></child></node>")
|
|
561
|
+
{
|
|
562
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\n<child>\n<sub>text</sub>\n</child>\n</node>\n"), STR(""), format_indent);
|
|
563
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\nA<child>\nAA<sub>text</sub>\nA</child>\n</node>\n"), STR("A"), format_indent);
|
|
564
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\nAB<child>\nABAB<sub>text</sub>\nAB</child>\n</node>\n"), STR("AB"), format_indent);
|
|
565
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\nABC<child>\nABCABC<sub>text</sub>\nABC</child>\n</node>\n"), STR("ABC"), format_indent);
|
|
566
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\nABCD<child>\nABCDABCD<sub>text</sub>\nABCD</child>\n</node>\n"), STR("ABCD"), format_indent);
|
|
567
|
+
CHECK_NODE_EX(doc, STR("<node attr=\"1\">\nABCDE<child>\nABCDEABCDE<sub>text</sub>\nABCDE</child>\n</node>\n"), STR("ABCDE"), format_indent);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
TEST(write_pcdata_null)
|
|
571
|
+
{
|
|
572
|
+
xml_document doc;
|
|
573
|
+
doc.append_child(STR("node")).append_child(node_pcdata);
|
|
574
|
+
|
|
575
|
+
CHECK_NODE(doc, STR("<node/>"));
|
|
576
|
+
CHECK_NODE_EX(doc, STR("<node />\n"), STR("\t"), format_indent);
|
|
577
|
+
CHECK_NODE_EX(doc, STR("<node></node>"), STR("\t"), format_raw | format_no_empty_element_tags);
|
|
578
|
+
CHECK_NODE_EX(doc, STR("<node></node>\n"), STR("\t"), format_indent | format_no_empty_element_tags);
|
|
579
|
+
|
|
580
|
+
doc.first_child().append_child(node_pcdata);
|
|
581
|
+
|
|
582
|
+
CHECK_NODE(doc, STR("<node></node>"));
|
|
583
|
+
CHECK_NODE_EX(doc, STR("<node></node>\n"), STR("\t"), format_indent);
|
|
584
|
+
CHECK_NODE_EX(doc, STR("<node></node>\n"), STR("\t"), format_indent | format_no_empty_element_tags);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
TEST(write_pcdata_basic)
|
|
588
|
+
{
|
|
589
|
+
xml_document doc;
|
|
590
|
+
doc.append_child(STR("node")).append_child(node_pcdata).set_value(STR("text"));
|
|
591
|
+
|
|
592
|
+
CHECK_NODE(doc, STR("<node>text</node>"));
|
|
593
|
+
CHECK_NODE_EX(doc, STR("<node>text</node>\n"), STR("\t"), format_indent);
|
|
594
|
+
CHECK_NODE_EX(doc, STR("<node>text</node>"), STR("\t"), format_raw | format_no_empty_element_tags);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
TEST(write_pcdata_empty_text)
|
|
598
|
+
{
|
|
599
|
+
xml_document doc;
|
|
600
|
+
doc.append_child(STR("node")).text().set(STR(""));
|
|
601
|
+
|
|
602
|
+
CHECK_NODE(doc, STR("<node/>"));
|
|
603
|
+
CHECK_NODE_EX(doc, STR("<node />\n"), STR("\t"), format_indent);
|
|
604
|
+
CHECK_NODE_EX(doc, STR("<node></node>"), STR("\t"), format_raw | format_no_empty_element_tags);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
TEST(write_pcdata_whitespace_fixedpoint)
|
|
608
|
+
{
|
|
609
|
+
const char_t* data = STR("<node> test <child>\n <sub/>\n </child>\n</node>");
|
|
610
|
+
|
|
611
|
+
static const unsigned int flags_parse[] =
|
|
612
|
+
{
|
|
613
|
+
0,
|
|
614
|
+
parse_ws_pcdata,
|
|
615
|
+
parse_ws_pcdata_single,
|
|
616
|
+
parse_trim_pcdata
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
static const unsigned int flags_format[] =
|
|
620
|
+
{
|
|
621
|
+
0,
|
|
622
|
+
format_raw,
|
|
623
|
+
format_indent
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
for (unsigned int i = 0; i < sizeof(flags_parse) / sizeof(flags_parse[0]); ++i)
|
|
627
|
+
{
|
|
628
|
+
xml_document doc;
|
|
629
|
+
CHECK(doc.load_string(data, flags_parse[i]));
|
|
630
|
+
|
|
631
|
+
for (unsigned int j = 0; j < sizeof(flags_format) / sizeof(flags_format[0]); ++j)
|
|
632
|
+
{
|
|
633
|
+
std::string saved = write_narrow(doc, flags_format[j], encoding_auto);
|
|
634
|
+
|
|
635
|
+
xml_document rdoc;
|
|
636
|
+
CHECK(rdoc.load_buffer(&saved[0], saved.size(), flags_parse[i]));
|
|
637
|
+
|
|
638
|
+
std::string rsaved = write_narrow(rdoc, flags_format[j], encoding_auto);
|
|
639
|
+
|
|
640
|
+
CHECK(saved == rsaved);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
TEST_XML_FLAGS(write_mixed, "<node><child1/><child2>pre<![CDATA[data]]>mid<!--comment--><test/>post<?pi value?>fin</child2><child3/></node>", parse_full)
|
|
646
|
+
{
|
|
647
|
+
CHECK_NODE(doc, STR("<node><child1/><child2>pre<![CDATA[data]]>mid<!--comment--><test/>post<?pi value?>fin</child2><child3/></node>"));
|
|
648
|
+
CHECK_NODE_EX(doc, STR("<node>\n<child1 />\n<child2>pre<![CDATA[data]]>mid<!--comment-->\n<test />post<?pi value?>fin</child2>\n<child3 />\n</node>\n"), STR("\t"), 0);
|
|
649
|
+
CHECK_NODE_EX(doc, STR("<node>\n\t<child1 />\n\t<child2>pre<![CDATA[data]]>mid<!--comment-->\n\t\t<test />post<?pi value?>fin</child2>\n\t<child3 />\n</node>\n"), STR("\t"), format_indent);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
TEST_XML(write_no_empty_element_tags, "<node><child1/><child2>text</child2><child3></child3></node>")
|
|
653
|
+
{
|
|
654
|
+
CHECK_NODE(doc, STR("<node><child1/><child2>text</child2><child3/></node>"));
|
|
655
|
+
CHECK_NODE_EX(doc, STR("<node><child1></child1><child2>text</child2><child3></child3></node>"), STR("\t"), format_raw | format_no_empty_element_tags);
|
|
656
|
+
CHECK_NODE_EX(doc, STR("<node>\n\t<child1></child1>\n\t<child2>text</child2>\n\t<child3></child3>\n</node>\n"), STR("\t"), format_indent | format_no_empty_element_tags);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
TEST_XML_FLAGS(write_roundtrip, "<node><child1 attr1='value1' attr2='value2'/><child2 attr='value'>pre<![CDATA[data]]>mid<text&escape<!--comment--><test/>post<?pi value?>fin</child2><child3/></node>", parse_full)
|
|
660
|
+
{
|
|
661
|
+
const unsigned int flagset[] = { format_indent, format_raw, format_no_declaration, format_indent_attributes, format_no_empty_element_tags, format_attribute_single_quote };
|
|
662
|
+
size_t flagcount = sizeof(flagset) / sizeof(flagset[0]);
|
|
663
|
+
|
|
664
|
+
for (size_t i = 0; i < (size_t(1) << flagcount); ++i)
|
|
665
|
+
{
|
|
666
|
+
unsigned int flags = 0;
|
|
667
|
+
|
|
668
|
+
for (size_t j = 0; j < flagcount; ++j)
|
|
669
|
+
if (i & (size_t(1) << j))
|
|
670
|
+
flags |= flagset[j];
|
|
671
|
+
|
|
672
|
+
std::string contents = write_narrow(doc, flags, encoding_utf8);
|
|
673
|
+
|
|
674
|
+
xml_document verify;
|
|
675
|
+
CHECK(verify.load_buffer(contents.c_str(), contents.size(), parse_full));
|
|
676
|
+
CHECK(test_write_narrow(verify, flags, encoding_utf8, contents.c_str(), contents.size()));
|
|
677
|
+
|
|
678
|
+
xml_document verifyws;
|
|
679
|
+
CHECK(verifyws.load_buffer(contents.c_str(), contents.size(), parse_full | parse_ws_pcdata));
|
|
680
|
+
CHECK(test_write_narrow(verifyws, flags, encoding_utf8, contents.c_str(), contents.size()));
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
TEST(write_flush_coverage)
|
|
685
|
+
{
|
|
686
|
+
xml_document doc;
|
|
687
|
+
|
|
688
|
+
// this creates a node that uses short sequences of lengths 1-6 for output
|
|
689
|
+
xml_node n = doc.append_child(STR("n"));
|
|
690
|
+
|
|
691
|
+
xml_attribute a = n.append_attribute(STR("a"));
|
|
692
|
+
|
|
693
|
+
xml_attribute b = n.append_attribute(STR("b"));
|
|
694
|
+
b.set_value(STR("<&\""));
|
|
695
|
+
|
|
696
|
+
n.append_child(node_comment);
|
|
697
|
+
|
|
698
|
+
size_t basel = save_narrow(doc, format_raw, encoding_auto).size();
|
|
699
|
+
size_t bufl = 2048;
|
|
700
|
+
|
|
701
|
+
for (size_t l = 0; l <= basel; ++l)
|
|
702
|
+
{
|
|
703
|
+
std::basic_string<char_t> pad(bufl - l, STR('v'));
|
|
704
|
+
a.set_value(pad.c_str());
|
|
705
|
+
|
|
706
|
+
std::string s = save_narrow(doc, format_raw, encoding_auto);
|
|
707
|
+
CHECK(s.size() == basel + bufl - l);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
#ifndef PUGIXML_NO_EXCEPTIONS
|
|
712
|
+
struct throwing_writer: xml_writer
|
|
713
|
+
{
|
|
714
|
+
void write(const void*, size_t) PUGIXML_OVERRIDE
|
|
715
|
+
{
|
|
716
|
+
throw std::runtime_error("write failed");
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
TEST_XML(write_throw_simple, "<node><child/></node>")
|
|
721
|
+
{
|
|
722
|
+
try
|
|
723
|
+
{
|
|
724
|
+
throwing_writer w;
|
|
725
|
+
doc.print(w);
|
|
726
|
+
|
|
727
|
+
CHECK_FORCE_FAIL("Expected exception");
|
|
728
|
+
}
|
|
729
|
+
catch (std::runtime_error&)
|
|
730
|
+
{
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
TEST_XML(write_throw_encoding, "<node><child/></node>")
|
|
735
|
+
{
|
|
736
|
+
try
|
|
737
|
+
{
|
|
738
|
+
throwing_writer w;
|
|
739
|
+
doc.print(w, STR("\t"), format_default, encoding_utf32_be);
|
|
740
|
+
|
|
741
|
+
CHECK_FORCE_FAIL("Expected exception");
|
|
742
|
+
}
|
|
743
|
+
catch (std::runtime_error&)
|
|
744
|
+
{
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
#endif
|
|
748
|
+
|
|
749
|
+
TEST_XML(write_skip_control_chars, "<a>\f\t\n\x0F\x19</a>")
|
|
750
|
+
{
|
|
751
|
+
CHECK_NODE_EX(doc.first_child(), STR("<a>\t\n</a>\n"), STR(""), pugi::format_default | pugi::format_skip_control_chars);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
TEST_XML(write_keep_control_chars, "<a>\f\t\n\x0F\x19</a>")
|
|
755
|
+
{
|
|
756
|
+
CHECK_NODE_EX(doc.first_child(), STR("<a>\t\n</a>\n"), STR(""), pugi::format_default);
|
|
757
|
+
}
|