testutils

package
v3.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2023 License: AGPL-3.0, AGPL-3.0-only Imports: 14 Imported by: 0

Documentation

Overview

Package testutils provides test methods that are not intended to be exported.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRenderNotSupported = errors.New("rendering PDF files is not supported on this system")
)

Errors.

Functions

func CompareDictionariesDeep

func CompareDictionariesDeep(d1, d2 *core.PdfObjectDictionary) bool

CompareDictionariesDeep does a deep comparison of `d1` and `d2` and returns true if equal.

func CompareImages

func CompareImages(img1, img2 image.Image) (bool, error)

CompareImages compares the specified images at pixel level.

func ComparePNGFiles

func ComparePNGFiles(file1, file2 string) (bool, error)

ComparePNGFiles compares the specified PNG files.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies the `src` file to `dst`.

func HashFile

func HashFile(file string) (string, error)

HashFile generates an MD5 hash from the contents of the specified file.

func ParseIndirectObjects

func ParseIndirectObjects(rawpdf string) (map[int64]core.PdfObject, error)

ParseIndirectObjects parses a sequence of indirect/stream objects sequentially from a `rawpdf` text. Great for testing.

func ReadPNG

func ReadPNG(file string) (image.Image, error)

ReadPNG reads and returns the specified PNG file.

func RenderPDFToPNGs

func RenderPDFToPNGs(pdfPath string, dpi int, outpathTpl string) error

RenderPDFToPNGs uses ghostscript (gs) to render the specified PDF file into a set of PNG images (one per page). PNG images will be named xxx-N.png where N is the number of page, starting from 1.

func RunRenderTest

func RunRenderTest(t *testing.T, pdfPath, outputDir, baselineRenderPath string, saveBaseline bool)

RunRenderTest renders the PDF file specified by `pdfPath` to the `outputDir` and compares the output PNG files to the golden files found at the `baselineRenderPath` location. If the specified PDF file is new (there are no golden files) and the `saveBaseline` parameter is set to true, the output render files are saved to the `baselineRenderPath`.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL