From d8acb448de09e0e453d4b0b7a511c6e2aa5e81d9 Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Mon, 17 Feb 2025 10:47:14 +0000 Subject: [PATCH] [add] coverage --- changelog.md | 3 +++ package.json | 2 +- src/Pdfbox3.xqm | 2 +- tests/test.xqm | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index c974278..8c3e87d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## 0.2.5 2025-02-17 +* rename property pages to pageCount +* increase test coverage ## 0.2.4 2025-02-16 * Add `property` * rewrite `report` to return CSV style data diff --git a/package.json b/package.json index 1a39c2f..2147234 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfbox", - "version": "0.2.4", + "version": "0.2.5", "description": "A BaseX interface to Apache Pdfbox version 3", "main": "src/Pdfbox3.xqm", "homepage": "https://github.com/expkg-zone58/pdfbox#readme", diff --git a/src/Pdfbox3.xqm b/src/Pdfbox3.xqm index 1d5b03d..0826f19 100644 --- a/src/Pdfbox3.xqm +++ b/src/Pdfbox3.xqm @@ -116,7 +116,7 @@ as xs:base64Binary{ values are sequences of functions to get property from $pdf object :) declare %private variable $pdfbox:property-map:=map{ - "pages": pdfbox:page-count#1, + "pageCount": pdfbox:page-count#1, "hasOutline": pdfbox:hasOutline#1, diff --git a/tests/test.xqm b/tests/test.xqm index 5c041bb..0c12710 100644 --- a/tests/test.xqm +++ b/tests/test.xqm @@ -112,6 +112,72 @@ function test:password-good(){ return unit:assert(true()) }; +(:~ Test for pdfbox:binary function :) +declare %unit:test +function test:binary(){ + let $pdf:=test:open("samples.pdf/BaseX100.pdf") + let $binary:=pdfbox:binary($pdf) + return unit:assert(exists($binary)) +}; + +(:~ Test for pdfbox:save function :) +declare %unit:test +function test:save(){ + let $pdf:=test:open("samples.pdf/BaseX100.pdf") + let $dest:=file:create-temp-file("test-save",".pdf") + let $savedPath:=pdfbox:save($pdf, $dest) + return unit:assert-equals($savedPath, $dest) +}; + +(:~ Test for pdfbox:property function :) +declare %unit:test +function test:property(){ + let $pdf:=test:open("samples.pdf/BaseX100.pdf") + let $pages:=pdfbox:property($pdf, "pageCount") + return unit:assert(true()) +}; + +(:~ Test for pdfbox:property function :) +declare %unit:test("expected", "pdfbox:property") +function test:property-bad(){ + let $pdf:=test:open("samples.pdf/BaseX100.pdf") + let $title:=pdfbox:property($pdf, "totle") + return unit:assert(exists($title)) +}; +(:~ Test for pdfbox:defined-properties function :) +declare %unit:test +function test:defined-properties(){ + let $properties:=pdfbox:defined-properties() + return unit:assert(exists($properties)) +}; + +(:~ Test for pdfbox:report function :) +declare %unit:test +function test:report(){ + let $pdfPaths:=("samples.pdf/BaseX100.pdf", "samples.pdf/icelandic-dictionary.pdf") + !test:resolve(.) + let $report:=pdfbox:report($pdfPaths) + return unit:assert(exists($report?names) and exists($report?records)) +}; + +(:~ Test for pdfbox:hasOutline function :) +declare %unit:test +function test:hasOutline(){ + let $pdf:=test:open("samples.pdf/BaseX100.pdf") + let $hasOutline:=pdfbox:hasOutline($pdf) + return unit:assert(not($hasOutline)) +}; + +(:~ Test for pdfbox:hasLabels function :) +declare %unit:test +function test:hasLabels(){ + let $pdf:=test:open("samples.pdf/BaseX100.pdf") + let $hasLabels:=pdfbox:hasLabels($pdf) + return unit:assert($hasLabels) +}; + + + (:---------------------------------------:) declare function test:open($file as xs:string,$opts as map(*)) as item(){