Leptonica 1.68
C Image Processing Library

regutils.h File Reference

Regression test parameter packer. More...

Go to the source code of this file.

Data Structures

struct  L_RegParams

Typedefs

typedef struct L_RegParams L_REGPARAMS

Enumerations

enum  { L_REG_GENERATE = 0, L_REG_COMPARE = 1, L_REG_DISPLAY = 2 }

Detailed Description

Regression test parameter packer.

 Contains this regression test parameter packaging struct
     struct L_RegParams


 The regression test utility allows you to write regression tests
 that compare results with existing "golden files".

 Such regression tests can be called in three ways.
 For example, for distance_reg:

     Case 1: distance_reg generate
         This generates golden files in /tmp for the reg test.

     Case 2: distance_reg compare
         This runs the test against the set of golden files.  It
         appends to 'outfile.txt' either "SUCCESS" or "FAILURE",
         as well as the details of any parts of the test that failed.
         It writes to a temporary file stream (fp)

     Case 3: distance_reg [display]
         This runs the test but makes no comparison of the output
         against the set of golden files.  In addition, this displays
         images and plots that are specified in the test under
         control of the display variable.  Display is enabled only
         for this case.  Using 'display' on the command line is optional.

 Regression tests follow the pattern given below.  In an actual
 case, comparisons of pix and of files can occur in any order.
 We give a specific order here for clarity.

     L_REGPARAMS  *rp;  // holds data required by the test functions

     // Setup variables; optionally open stream
     if (regTestSetup(argc, argv, &rp))
         return 1;

     // Test pairs of generated pix for identity.  This compares
     // two pix; no golden file is generated.
     regTestComparePix(rp, pix1, pix2);

     // Test pairs of generated pix for similarity.  This compares
     // two pix; no golden file is generated.  The last arg determines
     // if stats are to be written to stderr.
     regTestCompareSimilarPix(rp, pix1, pix2, 15, 0.001, 0);

     // Generation of <newfile*> outputs and testing for identity
     // These files can be anything, of course.
     regTestCheckFile(rp, <newfile0>);
     regTestCheckFile(rp, <newfile1>);

     // Test pairs of output golden files for identity.  Here we
     // are comparing golden files 4 and 5.
     regTestCompareFiles(rp, 4, 5);

     // "Write and check".  This writes a pix using a canonical
     // formulation for the local filename and either:
     //     case 1: generates a golden file
     //     case 2: compares the local file with a golden file
     //     case 3: generates local files and displays
     // Here we write the pix compressed with png and jpeg, respectively;
     // Then check against the golden file.  The internal @index
     // is incremented; it is embedded in the local filename and,
     // if generating, in the golden file as well.
     regTestWritePixAndCheck(rp, pix1, IFF_PNG);
     regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG);

     // Display if reg test was called in 'display' mode
     pixDisplayWithTitle(pix1, 100, 100, NULL, rp->display);

     // Clean up and output result
     regTestCleanup(rp);

Definition in file regutils.h.


Typedef Documentation

typedef struct L_RegParams L_REGPARAMS

Definition at line 110 of file regutils.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
L_REG_GENERATE 
L_REG_COMPARE 
L_REG_DISPLAY 

Definition at line 114 of file regutils.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines