Index: trunk/psLib/test/TABLE-SDRS-CH06-DataManip
===================================================================
--- trunk/psLib/test/TABLE-SDRS-CH06-DataManip	(revision 13123)
+++ trunk/psLib/test/TABLE-SDRS-CH06-DataManip	(revision 13123)
@@ -0,0 +1,470 @@
+-------------------------------------------------------------------------------
+CVS Checkin: 4-23
+    tap_psPolynomialEval1D.c
+    tap_psPolynomialEval2D.c
+    tap_psPolynomialEval3D.c
+    tap_psPolynomialEval4D.c
+    tap_psMinimizeLMM.c
+    tap_psFunc01.c
+    tap_psMinimizePowell.c
+    tap_psPolyFit1D.c
+    tap_psPolyFit2D.c
+    tap_psPolyFit3D.c
+    tap_psPolyFit4D.c
+    tap_psMatrix01.c
+    tap_psMatrix02.c
+    tap_psSpline1D.c
+    tap_psSparse.c
+P40
+    imageops/tap_psImageStructManip.c
+
+Add:
+    tap_psHistogram
+Remove:
+    tap_psHist00.c
+    tap_psHist01.c
+    tap_psHist02.c
+    tap_psHist03.c
+-------------------------------------------------------------------------------
+			Unallowed	Types	Sizes	Level	Algorithm
+			Params				of
+							Testing
+ALPHA order
+psVectorSort()
+			10		10	2	10
+    We only test with NULL, size 1, and size 7 vectors.
+    Add a test with NULL input, non-NULL output.
+psVectorSortIndex()
+			10		10	2	10
+    We only test with NULL, size 1, and size 7 vectors.
+    Add a test with NULL input, non-NULL output.
+psVectorStats()		5		10	5	5
+    Must review these files more.
+    More extensie robust stats?
+psStatsAlloc()
+			na		na	na	10
+psStatsOptionFromString()
+			NONE		NONE	NONE	NONE
+psStatsOptionToString()
+			NONE		NONE	NONE	NONE
+psStatsFromString()
+			NONE		NONE	NONE	NONE
+psStatsToString()
+			NONE		NONE	NONE	NONE
+psStatsSingleOption()
+			NONE		NONE	NONE	NONE
+psStatsGetValue()
+			NONE		NONE	NONE	NONE
+psVectorCountPixelMask()10		10	8	10	na
+    mathtypes/tst_psVector.c
+psHistogramAlloc()
+			10		na	10	10
+psHistogramAllocGeneric()
+			10		na	10	10
+psVectorHistogram()
+			8		na	10	8
+psPolynomial1DAlloc()
+			8		na	na	5
+    Can we test with negative polynomial order?
+    How about verifying the data is allocated, and initialized?
+psPolynomial2DAlloc()
+			8		na	na	5
+    Can we test with negative polynomial order?
+psPolynomial3DAlloc()
+			8		na	na	5
+    Can we test with negative polynomial order?
+psPolynomial4DAlloc()
+			8		na	na	5
+    Can we test with negative polynomial order?
+psPolynomial1DEval()
+			10		10	1	8
+    We only allocate polynomials with 4 terms
+    We should ensure that asking for negatiev number of terms fails nicely.
+psPolynomial2DEval()
+			10		10	1	5
+    We only allocate polynomials with 4 terms
+	Must vary x,y number of terms.
+psPolynomial3DEval()
+			10		10	1	5
+    We only allocate polynomials with 4 terms
+	Must vary x,y,z number of terms.
+psPolynomial4DEval()
+			10		10	1	5
+    We only allocate polynomials with 4 terms
+	Must vary w,x,y,z number of terms.
+psPolynomial1DEvalVector()
+			10		10	5	9
+psPolynomial2DEvalVector()
+			10		10	5	9
+psPolynomial3DEvalVector()
+			10		10	5	9
+psPolynomial4DEvalVector()
+			10		10	5	9
+psPolynomial1DfromMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psPolynomial2DfromMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psPolynomial3DfromMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psPolynomial4DfromMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psPolynomial1DtoMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psPolynomial2DtoMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psPolynomial3DtoMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psPolynomial4DtoMetadata()10		10	10	10	na
+    types/tap_psMetadata_polynomials.c
+psSpline1DAlloc()
+			na		na	na	10
+psSpline1DEval()
+			8		na	5	8
+    There should be a PS_ASSERT_PTR_NON_NULL(spline->knots) before we assert type:
+    PS_ASSERT_PTR_NON_NULL(spline, NULL);
+    PS_ASSERT_VECTOR_TYPE(spline->knots, PS_TYPE_F32, NULL);
+psSpline1DEvalVector()
+			8		na	5	8
+psGaussian()		na		na	na	5	na
+    math/tap_psFunc01.c
+    This test merely compares psGaussian results agaisnt preset vectors.
+    Add tests to generate a vector of data, then run psVectorStats() on it.
+psMinimizationAlloc()
+			10		10	10	10
+    Completely tested.
+psMinConstrainAlloc()
+			10		10	10	10
+    Completely tested, however the SDRS completely disagrees with the code.
+    What happened to the following members?
+        psVector *paramMax;
+        psVector *paramMin;
+        psVector *paramDelta;
+    And a new member:
+	psMinimizeLMLimitFunc checkLimits;
+psMinimizeLMChi2()
+			5		3	1	1
+    XXX: Add tests for
+        covar arg set to non-NULL
+        constraint set to non-NULL
+	Set x->vectors to NULL, or use wrong types
+	yWt (errors) vector set to incorrect size, type.
+psMinimizeGaussNewtonDelta()0		0	0	0	0
+    NONE
+psMinimizePowell()	0		0	0	0	na
+    The bad param tests are all commented out due to seg faults
+    Basically, everthing is commented out due to seg faults
+psMinimizeChi2Powell()	0		0	0	0	0
+    NONE
+psVectorFitPolynomial1D()
+			0		10	7	9
+    Must add unallowed input parameters, maybe vary the poly orders.
+    4D has some tests that are failing, but should not be.
+psVectorFitPolynomial2D()
+			0		10	7	9
+    DITTO
+psVectorFitPolynomial3D()
+			0		10	7	9
+    DITTO
+psVectorFitPolynomial4D()
+			0		10	7	9
+    DITTO
+psVectorClipFitPolynomial1D()
+			0		10	7	9
+    DITTO
+psVectorClipFitPolynomial2D()
+			0		10	7	9
+    DITTO
+psVectorClipFitPolynomial3D()
+			0		10	7	9
+    DITTO
+psVectorClipFitPolynomial4D()
+			0		10	7	9
+    DITTO
+psVectorFitSpline1D()	0		2	10	5	5
+psImageSubset()		10		2	1	10	na
+    in imageops dir. not math: tap_psImageStructManip.c
+    A single 128x256 image of type U32 is tested.
+psImageCopy()		10		10	8	10	na
+    in imageops dir. not math: tap_psImageStructManip.c
+    A single input 128x256 image of type F32 is tested, however it's
+	converted to all other allowed types.
+psImageTrim()		10		2	4	10	na
+    in imageops dir. not math: tap_psImageStructManip.c
+    A single 200x300 image of type F32 is tested.
+psImageFlip()		0		0	0	0	0
+    NONE
+psImageRow()		10		10	2	10	na
+    in imageops dir. not math: tap_psImageStructManip.c
+psImageCol()		10		10	2	10	na
+    in imageops dir. not math: tap_psImagePixelExtract.c
+    A single 3x3 image is used
+psImageSlice()		10		10	10	10	na
+    in imageops dir. not math: tap_psImagePixelExtract.c
+    Spend more time determining if all input params are tested, and all combos
+	as well.
+    SDRS seems to be out of date.
+psImageCut()		5		2	2	10	na
+    in imageops dir. not math: tap_psImagePixelExtract.c
+    SDRS seems to be incomplete and lots of unallowed input param combos are
+	probably not tested.
+    A single 200x300 input image of type F32 is tested.
+    
+psImageRadialCut()	10		2	2	10	na
+    in imageops dir. not math: tap_psImagePixelExtract.c
+    A single 200x300 input image of type F32 is tested.
+psImageRebin()		10		10	2	10	na
+    In imageops dir. not math: tap_psImageGeomManip.c
+    Only 16x16 images are rebinned into 4x4 images.  Try NxM.
+psImageResample()	10		2	2	10	na
+    In imageops dir. not math: tap_psImageGeomManip.c
+    A single 80x60 input image of type F32 is used.
+psImageRotate()		8		5	2	10	na
+    In imageops dir. not math: tap_psImageGeomManip.c
+    A single 64x64 input image is used
+    Only types F32 and S16 are tested
+    Image values are compared against a stored FITS file.  Where did the file
+	come from?
+    There is a potential autoconf directory problem with reading the FITS file.
+psImageShift()		10		5	5	10	na
+    In imageops dir. not math: tap_psImageGeomManip.c
+    Only 64x128 images are used.
+    Only types F32 and S16 are tested
+psImageRoll()		10		10	2	10	na
+    In imageops dir. not math: tap_psImageGeomManip.c
+    Only NxN square images are tested.
+psImageTransform()	0		2	2	5	na
+    In imageops dir. not math: tap_psImageGeomManip.c
+    A single 16x32 input image of type F32 is used
+    No attempt at unallowed input params, types, or sizes.
+psImageUnbin()		0		0	0	0	0
+    NONE
+psImageStats()		10		2	2	10	na
+    In imageops/tap_psImageStats.c
+    A single 10x10 input image of type F32 is used
+    subRegion tests are skipped because of a seg-fault
+psImageHistogram()	10		2	4	10	na
+    In imageops/tap_psImageStats.c
+    A single 16x15 input image of type F32 is used
+    numBins should be varied
+psImageCountPixelMask()	10		10	2	10	na
+    In imageops/tap_psImageStats.c
+    A single 10x10 input mask images used
+psImageFitPolynomial()	10		2	4	10	5
+    In imageops/tap_psImageStats.c
+    Only 10x10 images are used.
+    Only F32 and F64 are tested.
+psImageEvalPolynomial()	10		2	4	10	5
+    In imageops/tap_psImageStats.c
+    Only 10x10 images are used.
+    Only F32 and F64 are tested.
+psImagePixelInterpolate()
+			2		2	2	8	8
+    There's old code in imageops/tap_psImageInterpolate.c
+    Extensive code in mathtypes/tap_psImageInterpolate.c
+    A single 32x32 input image of type F32 is used
+    Merge param tests from imageops/tap_psImageInterpolate.c
+psImageBackground()	0		0	0	0	0
+    NONE
+psImageClip()		8		10	2	10	na
+    imageops/tap_psImagePixelManip.c
+    Only 256-128 images are tested
+    All types are tested
+    Should block off some individual tests
+psImageClipComplexRegion()0		0	0	0	0
+    NONE in tap files, there is an old imageops/tst_psImagePixelManip.c
+    Is this still in the new SDRS?
+psImageClipNaN()	8		5	2	10	na
+    imageops/tap_psImagePixelManip.c
+    Only 256-128 images are tested
+    Only F32 and F64 are tested
+    Should block off some individual tests
+psImageOverlaySection()	10		10	2	10	na
+    imageops/tap_psImagePixelManip.c
+    Only 128-by-256 images are tested
+    All types are tested
+    Should block off some individual tests
+psImageBicubeFit()	0		0	0	0	0
+    NONE
+psImageBicubeMin()	0		0	0	0	0
+    NONE
+psImageJpegColormapAlloc()
+			0		0	0	0	0
+    NONE
+psImageJpegColormapSet()0		0	0	0	0
+    NONE
+psImageJpeg()		0		0	0	0	0
+    NONE
+psImageGrowMask()	10		10	2	10	na
+    In imageops/tap_psImageMaskOps.c
+    psImageGrowMask() is currently growing a circular mask when the SDRS specs
+	a square mask.
+    All mask images are NxN
+psPixelsToMask()	10		10	10	2	na
+    In types/tap_psPixels_all.c
+    We never test pixels in the output image mask
+psPixelsFromMask()	10		10	2	2	na
+    In types/tap_psPixels_all.c
+    We never test pixels in the output psPixels
+    Should better separate individual tests
+psPixelsConcatenate()	?		?	?	?	na
+    This is not in the SDRS
+    We never test pixels in the output psPixels
+psImageMaskRegion()	5		10	10	10	na
+    In imageops/tap_psImageMaskOps.c
+    Generate tests with NULL input, bad input type, bad psRegion
+psImageKeepRegion()
+    In imageops/tap_psImageMaskOps.c
+    Generate tests with NULL input, bad input type, bad psRegion
+psImageMaskCircle()	5		10	2	5	na
+    In imageops/tap_psImageMaskOps.c
+    Generate tests with NULL input, bad input type, bad radius, etc
+    Seg faults are skipped for Nx1 and 1xN images
+psImageKeepCircle()	5		10	2	5	na
+    In imageops/tap_psImageMaskOps.c
+    Generate tests with NULL input, bad input type, bad radius, etc
+    Seg faults are skipped for Nx1 and 1xN images
+psBinaryOp()		?		?	?	?	?
+    Extensive tests in tap_psMatrixVectorArithmetic:01-04.c
+    Must review further.
+    Some are seg-faulting and failing to compile, so I removed from Makefile.am
+psUnaryOp()		?		?	?	?	?
+    Extensive tests in tap_psMatrixVectorArithmetic:01-04.c
+    Must review further.
+    Some are seg-faulting and failing to compile, so I removed from Makefile.am
+psMatrixLUD()		0		5	2	5	3
+    math/tap_psMatrix03.c
+    The NULL image argument seg-faults
+    Only 3x3 matrices, F32 and F64, are used.
+    Fairly low-level of testing
+psMatrixLUSolve()	0		5	2	5	3
+    math/tap_psMatrix03.c
+    The NULL image argument seg-faults
+    The NULL vector argument seg-faults
+    Only 3x3 matrices, F32 and F64, are used.
+    Fairly low-level of testing
+psMatrixGJSolve()	0		0	0	0	0
+    NONE
+psMatrixInvert()	0		5	2	5	3
+    math/tap_psMatrix04.c
+    Only 3x3 matrices, F32 and F64, are used.
+    The NULL image argument seg-faults
+    The NULL vector argument seg-faults
+    Fairly low-level of testing
+psMatrixDeterminant()	10		10	2	5	na
+    math/tap_psMatrix04.c
+    Only 3x3 matrices, F32 and F64, are used.
+    Fairly low-level of testing
+psMatrixMultiply()	0		5	2	5	na
+    math/tap_psMatrix05.c
+    Only 3x3 matrices, F32 and F64, are used.
+    No tests when args have different types.
+    No tests for bad input params.
+psMatrixTranspose()	10		10	4	8	na
+    math/tap_psMatrix01.c
+    Probably should N-by-M sizes
+    in file tap_psMatrix01.c
+    in file tap_psMatrix02.c
+	A few other tests with bad input parameters
+psMatrixEigenvectors()	0		5	2	5	na
+    math/tap_psMatrix06.c
+    Only 4x4 matrices, F32 and F64, are used.
+    No tests when args have different types.
+    No tests for bad input params.
+psMatrixToVector()	0		5	2	5	na
+    math/tap_psMatrix07.c
+    Only 1x3 and 3x1 matrices are used.
+    Only F32 and F64 types are used.
+    Lots of bad param tests are commented out due to seg faults
+psVectorToMatrix()	0		5	2	5	na
+    math/tap_psMatrix07.c
+    no bad param tests
+    Only 3x1 matrices are used.
+    Only F32 and F64 types are used.
+psSparseAlloc()
+			na		na	10	10	na
+psSparseMatrixElement()	0		na	na	na	na
+    math/tap_psSparse.c
+    This is not tested individually, however it is tested implictly.
+    Must write individual tests for it.
+psSparseVectorElement()	1		1	1	1	na
+    math/tap_psSparse.c
+    This is not tested individually, however it is tested implictly.
+    Must write individual tests for it.
+psSparseVectorElement()	1		1	1	1	na
+    math/tap_psSparse.c
+    This is not in the SDRS
+    This is not tested individually, however it is tested implictly.
+    Must write individual tests for it.
+psSparseMatrixTimesVector()1		1	1	1	na
+    math/tap_psSparse.c
+    This is not tested individually, however it is tested implictly.
+    Must write individual tests for it.
+psSparseResort()	1		1	1	1	na
+    math/tap_psSparse.c
+    This is not tested individually, however it is tested implictly.
+    Must write individual tests for it.
+psSparseSolve()		0		2	2	4	na
+    math/tap_psSparse.c
+    Must add param, types, and size tests.
+psVectorForwardFFT()	10		5	10	10	na
+    fft/tap_psVectorFFT.c
+    Add F64 tests
+psVectorBackwardFFT()	0		2	2	2	na
+    fft/tap_psVectorFFT.c
+    This is only tested implictly, once, along with the forward FFT test.
+psVectorPowerSpectrum()	0		0	0	0	0
+    fft/tst_psVectorFFT.c
+        There do not appear to be any tap tests.  Must look thru old files.
+psVectorComplexMultiply()0		0	0	0	0
+    NONE
+psImageForwardFFT()	10		5	10	10	na
+    fft/tap_psImageFFT.c
+    Need both F32 and F64 tests?
+psImageBackwardFFT()	0		2	2	2	na
+    fft/tap_psImageFFT.c
+    Need both F32 and F64 tests?
+    This is only tested implictly, once, along with the forward FFT test.
+psImagePowerSpectrum()	0		0	0	0	0
+    fft/tst_psImageFFT.c
+        There do not appear to be any tap tests.  Must look thru old files.
+psImageComplexMultiply()0		0	0	0	0
+    NONE
+psImageSmooth()		0		10	10	10	na
+    No bad param tests.
+    Don't you had bad param test lying around somewhere?
+psKernelAlloc()		8		na	na	8	na
+    imageops/tap_psImageConvolve.c
+    Consolidate with tap_psImageConvolve2.c
+psKernelGenerate()	8		5	5	4	na
+    imageops/tap_psImageConvolve.c
+    Some tests are skipped because of seg faults
+psImageConvolveDirect()	0		2	2	2	na
+    imageops/tap_psImageConvolve.c
+    These are completely commented away in tap_psImageConvolve.c and only
+	lightly tested in tap_psImageConvolve2.c
+psImageConvolveFFT()	0		0	0	2
+    imageops/tap_psImageConvolve2.c
+    Only lightly tested in tap_psImageConvolve2.c
+psRandomAlloc()		10		na	na	10	na
+    math/tap_psRandom.c
+psRandomReset()		5		na	na	8	na
+    math/tap_psRandom.c
+    The bad param test is commented out
+psRandomUniform()	8		na	na	10	na
+psRandomGaussian()	8		na	na	10	na
+psRandomPoisson()	8		na	na	10	na
+psEllipseMomentsToAxes()	0	0	0	0	0
+    NONE
+psEllipseAxesToShape()	0	0	0	0	0
+    NONE
+psEllipseShapeToAxes()	0	0	0	0	0
+    NONE
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+is the way
+
Index: trunk/psLib/test/imageops/Makefile.am
===================================================================
--- trunk/psLib/test/imageops/Makefile.am	(revision 13084)
+++ trunk/psLib/test/imageops/Makefile.am	(revision 13123)
@@ -21,5 +21,6 @@
 	tap_psImageConvolve2 \
 	tap_psImagePixelExtract \
-	tap_psImageInterpolate2
+	tap_psImageInterpolate2 \
+	tap_psImageMaskOps
 
 #	tap_psImageShiftKernel
Index: trunk/psLib/test/imageops/tap_psImageGeomManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageGeomManip.c	(revision 13084)
+++ trunk/psLib/test/imageops/tap_psImageGeomManip.c	(revision 13123)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-05-01 00:08:52 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-02 04:14:33 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -154,7 +154,7 @@
     plan_tests(237);
 
-    // testImageRebin()
-    // This function shall generate a rescaled version of a psImage structure
-    // derived from a specified statistics method.
+    // test psImageRebin()
+    // This function shall generate a rescaled version of a psImage
+    // structure derived from a specified statistics method.
     if (1) {
         psMemId id = psMemGetId();
@@ -295,5 +295,5 @@
         testRebinType(U16);
         testRebinType(S8);
-        // Verify the returned psImage structure is null and program execution
+        // Verify the returned psImage structure is NULL and program execution
         // doesn't stop, if the input image type is not supported.
         // Following should be an error for unsupported type
@@ -305,5 +305,5 @@
         ok(out == NULL, "psImageRebin returned NULL for unsupported type");
 
-        // Verify the returned psImage structure is null and program execution
+        // Verify the returned psImage structure is NULL and program execution
         // doesn't stop, if the mask type is not U8
         // Following should be an error for invallid mask type
@@ -314,10 +314,10 @@
         psFree(in);
 
-        // Verify the returned psImage structure is null and program execution
-        // doesn't stop, if the input parameter input is null.
+        // Verify the returned psImage structure is NULL and program execution
+        // doesn't stop, if the input parameter input is NULL.
         out2 = psImageRebin(NULL,NULL,NULL,0,1,&stats);
         ok(out2 == NULL, "psImageRebin returned NULL with NULL input");
 
-        // Verify the returned psImage structure is null and program execution
+        // Verify the returned psImage structure is NULL and program execution
         // doesn't stop, if the input parameter scale is less than or equal to zero.
         in = psImageAlloc(16, 16, PS_TYPE_F32);
@@ -327,12 +327,12 @@
         ok(out2 == NULL, "psImageRebin returned NULL when the scale was zero");
 
-        // Verify the returned psImage structure is null and program execution
-        // doesn't stop, if the input parameter stats is null.
-        // Following should be an error for stats null
+        // Verify the returned psImage structure is NULL and program execution
+        // doesn't stop, if the input parameter stats is NULL.
+        // Following should be an error for stats NULL
         // XXX: Verify error
         out2 = psImageRebin(NULL,in,NULL,0,1,NULL);
         ok(out2 == NULL, "psImageRebin returned an NULL when the stats was NULL");
 
-        // Verify the returned psImage structure is null and program execution
+        // Verify the returned psImage structure is NULL and program execution
         // doesn't stop, if the input parameter psStats structure member options
         // is zero or any value which doesn't correspond to a valid statistical
@@ -350,5 +350,5 @@
         ok(out2 == NULL, "psImageRebin returned an image though the stats options was PS_STAT_USE_RANGE");
 
-        // Verify the returned psImage structure is null and program execution
+        // Verify the returned psImage structure is NULL and program execution
         // doesn't stop, if the input parameter psStats structure member options
         // specifies more than one valid statistical method.
@@ -363,5 +363,5 @@
     }
 
-    // testImageRoll()
+    // test psImageRoll()
     if (1) {
         psMemId id = psMemGetId();
@@ -387,9 +387,7 @@
 
         in = psImageAlloc(cols,rows,PS_TYPE_F32);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                inRow[col] = (psF32)row+(psF32)col/1000.0f;
+        for (psS32 row=0;row<rows;row++) {
+            for (psS32 col=0;col<cols;col++) {
+                in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
             }
         }
@@ -397,6 +395,5 @@
         out = psImageRoll(NULL,in,0,0);
         bool errorFlag = false;
-        for (psS32 row=0;row<rows;row++)
-        {
+        for (psS32 row=0;row<rows;row++) {
             psF32 *inRow = in->data.F32[row];
             psF32 *outRow = out->data.F32[row];
@@ -519,9 +516,8 @@
 
 
-        // Verify the returned psImage structure pointer is null and program
-        // execution doesn't stop, if input parameter input is null.
+        // Verify the returned psImage structure pointer is NULL and program
+        // execution doesn't stop, if input parameter input is NULL.
         out2 = psImageRoll(NULL,NULL,0,0);
-        if (out2 != NULL)
-        {
+        if (out2 != NULL) {
             psError(PS_ERR_UNKNOWN, true,"psImageRoll did not return NULL though input image was NULL!?");
             return 2;
@@ -567,6 +563,5 @@
     }
 
-
-    // testImageRotate()
+    // test psImageRotate()
     if (1) {
         psMemId id = psMemGetId();
@@ -599,6 +594,5 @@
         psImage *sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
 
-        for(psS32 row=0;row<rows;row++)
-        {
+        for(psS32 row=0;row<rows;row++) {
             psF32 *fRow = fImg->data.F32[row];
             psS16 *sRow = sImg->data.S16[row];
@@ -612,5 +606,4 @@
         // is to verify the results manually and bless it for automated comparison
         // thereafter
-
 
         // write results of various rotates to a file and verify with truth images
@@ -796,6 +789,6 @@
         }
 //HERE
-        // Verify the returned psImage structure pointer is null and program
-        // execution doesn't stop, if the input parameter input is null.
+        // Verify the returned psImage structure pointer is NULL and program
+        // execution doesn't stop, if the input parameter input is NULL.
         // Following should be an error
         // XXX: Verify error
@@ -803,5 +796,5 @@
         ok(fOut == NULL, "NULL was returned when the input image was NULL");
 
-        // Verify the returned psImage structure pointer is null and program
+        // Verify the returned psImage structure pointer is NULL and program
         // execution doesn't stop, if the specified interpolation mode is unallowed
         // Following should be an error for unallowed interpolation type
@@ -882,6 +875,6 @@
         ok(fRecycle == fOut, "psImageShift did recycle my image");
 
-        // Verify the returned psImage structure pointer is null and program
-        // execution doesn't stop, if the input psImage structure pointer is null.
+        // Verify the returned psImage structure pointer is NULL and program
+        // execution doesn't stop, if the input psImage structure pointer is NULL.
         // Following should be an error
         // XXX: Verify error
@@ -889,5 +882,5 @@
         ok(fOut == NULL, "psImageShift did return NULL given a NULL input image");
 
-        // Verify the returned psImage structure is null and program execution
+        // Verify the returned psImage structure is NULL and program execution
         // doesn't stop, if the specified interpolation mode is unallowed.
         // Following should be an error for unallowed interpolation mode
@@ -901,8 +894,7 @@
 
 
-    // testImageResample()
+    // test psImageResample()
     if (1) {
         psMemId id = psMemGetId();
-
         psS32 rows = 60;
         psS32 cols = 80;
@@ -911,10 +903,8 @@
         psErr *err;
 
-        psImage *image = psImageAlloc(cols,rows,PS_TYPE_F32);
-        for(psS32 row=0;row<rows;row++)
-        {
-            psF32 *imageRow = image->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                imageRow[col] = row+2*col;
+        psImage *image = psImageAlloc(cols, rows, PS_TYPE_F32);
+        for(psS32 row=0;row<rows;row++) {
+            for (psS32 col=0;col<cols;col++) {
+                image->data.F32[row][col] = row+2*col;
             }
         }
@@ -925,9 +915,6 @@
         ok(result == orig, "psImageResample() recycled image");
         ok(result->type.type == PS_TYPE_F32, "psImageResample() produced the correct type");
-
-
         ok(result->numCols == image->numCols*scale && result->numRows == image->numRows*scale,
            "psImageResample() produced the correct size");
-
 
         bool errorFlag = false;
@@ -939,6 +926,5 @@
             psMaskType maskVal;
             psF32 truthValue;
-            for(psS32 row=0;row<result->numRows;row++)
-            {
+            for(psS32 row=0;row<result->numRows;row++) {
                 for (psS32 col=0;col<result->numCols;col++) {
 //                    truthValue = psImagePixelInterpolate(image,
@@ -961,5 +947,5 @@
         ok(!errorFlag, "psImageResample() produced the correct data values");
 
-        // verify that image=null is handled properly.
+        // verify that image=NULL is handled properly.
         psErrorClear();
         result = psImageResample(result,NULL,scale,PS_INTERPOLATE_FLAT);
@@ -1002,5 +988,5 @@
 
 
-    // testImageTransform()
+    // test psImageTransform()
     if (1) {
         psMemId id = psMemGetId();
@@ -1013,22 +999,13 @@
 
         psImage *in = psImageAlloc(cols,rows,PS_TYPE_F32);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                inRow[col] = (psF32)row+(psF32)col/1000.0f;
+        for (psS32 row=0;row<rows;row++) {
+            for (psS32 col=0;col<cols;col++) {
+                in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
             }
         }
         P_PSIMAGE_SET_COL0(in, 1);
-        psImage *out = psImageTransform(NULL,
-                                        NULL,
-                                        in,
-                                        NULL,
-                                        0,
-                                        trans,
-                                        psRegionSet(1,1+cols*2,0,rows*2),
-                                        NULL,
-                                        PS_INTERPOLATE_FLAT,
-                                        -1);
+        psImage *out = psImageTransform(NULL, NULL, in, NULL, 0, trans,
+                                        psRegionSet(1,1+cols*2,0,rows*2), NULL,
+                                        PS_INTERPOLATE_FLAT, -1);
 
         ok(out != NULL, "psImageTransform() returned non-NULL");
@@ -1036,5 +1013,5 @@
         ok(out->numRows == rows*2 && out->numCols == cols*2, "psImageTransform() produced the correct size");
 
-        if (0) {
+        if (1) {
             psMemId id = psMemGetId();
             psImageInterpolateOptions *tmpIntOpts = psImageInterpolateOptionsAlloc(
@@ -1045,7 +1022,5 @@
             psMaskType maskVal;
             bool errorFlag = false;
-            for (psS32 row=0;row<out->numRows;row++)
-            {
-                psF32 *outRow = out->data.F32[row];
+            for (psS32 row=0;row<out->numRows;row++) {
                 for (psS32 col=0;col<cols;col++) {
                     psImageInterpolate(&imgVal, &varVal, &maskVal, 
@@ -1054,6 +1029,7 @@
                                        tmpIntOpts);
                     float inValue = imgVal;
-                    if (fabsf(outRow[col] - inValue) > 0.01) {
-                        diag("out at %d,%d was %g, expected %g", col,row,outRow[col], inValue);
+                    if (fabsf(out->data.F32[row][col] - inValue) > 0.01) {
+                        diag("out at %d,%d was %g, expected %g", col,row,
+                              out->data.F32[row][col], inValue);
                         errorFlag = true;
                     }
Index: trunk/psLib/test/imageops/tap_psImageMaskOps.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageMaskOps.c	(revision 13084)
+++ trunk/psLib/test/imageops/tap_psImageMaskOps.c	(revision 13123)
@@ -3,6 +3,6 @@
  *  @brief Contains the tests for psMaskOps.[ch]
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-02-09 20:40:22 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-02 04:14:33 $
  *
  *  XXX: In general, the image tests with (1, N) and (N, 1) failed and have
@@ -721,4 +721,5 @@
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
+    // XXX: These seg fault
     if (0) genericImageMaskCircleTest(N, 1, N/2, 1, N/4);
     if (0) genericImageMaskCircleTest(1, N, 1, N/2, N/4);
@@ -734,4 +735,5 @@
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
+    // XXX: These seg fault
     if (0) genericImageKeepCircleTest(N, 1, N/2, 1, N/4);
     if (0) genericImageKeepCircleTest(1, N, 1, N/2, N/4);
Index: trunk/psLib/test/imageops/tap_psImagePixelExtract.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImagePixelExtract.c	(revision 13084)
+++ trunk/psLib/test/imageops/tap_psImagePixelExtract.c	(revision 13123)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-04-26 22:18:03 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-05-02 04:14:33 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -17,5 +17,5 @@
 #include "pstap.h"
 
-psS32 main( psS32 argc, char* argv[] )
+psS32 main(psS32 argc, char* argv[])
 {
     psLogSetFormat("HLNM");
@@ -23,5 +23,5 @@
     plan_tests(248);
 
-    // testImageSlice()
+    // test psImageSlice()
     {
         psMemId id = psMemGetId();
@@ -31,7 +31,7 @@
         const psS32 n = r / 4 -1;
         psImage* image;
-        psPixels* positions = psPixelsAlloc( r );
-        psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK );
-        psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN );
+        psPixels* positions = psPixelsAlloc(r);
+        psImage* mask = psImageAlloc(c, r, PS_TYPE_MASK);
+        psStats* stat = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
     
 
@@ -46,8 +46,8 @@
         // cases should be used for each possible direction. Data region cases
         // should include 0x0, 1x1, Nx1, 1xN, NxN, MxN
-        for ( psS32 row = 0;row < r;row++ ) {
+        for (psS32 row = 0;row < r;row++) {
             psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row];
-            for ( psS32 col = 0;col < c;col++ ) {
-                maskRow[ col ] = 0;
+            for (psS32 col = 0;col < c;col++) {
+                maskRow[col] = 0;
             }
         }
@@ -58,10 +58,10 @@
             psVector* out = NULL; \
             bool errorFlag = false; \
-            image = psImageAlloc( c, r, PS_TYPE_##TYPE ); \
-            for ( psS32 row = 0;row < r;row++ ) { \
-                ps##TYPE *imageRow = image->data.TYPE[ row ]; \
+            image = psImageAlloc(c, r, PS_TYPE_##TYPE); \
+            for (psS32 row = 0;row < r;row++) { \
+                ps##TYPE *imageRow = image->data.TYPE[row]; \
                 ps##TYPE rowOffset = row * 2; \
-                for ( psS32 col = 0;col < c;col++ ) { \
-                    imageRow[ col ] = col + rowOffset; \
+                for (psS32 col = 0;col < c;col++) { \
+                    imageRow[col] = col + rowOffset; \
                 } \
             } \
@@ -111,23 +111,23 @@
         //
         #define PSIMAGESLICE_TEST(TYPE) \
-        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0 ); \
-        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1 ); \
-        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2 ); \
-        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 ); \
+        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0); \
+        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1); \
+        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2); \
+        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3); \
         \
-        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4 ); \
-        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5 ); \
-        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 ); \
-        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 ); \
+        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4); \
+        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5); \
+        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6); \
+        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7); \
         \
-        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 ); \
-        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9 ); \
-        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10 ); \
-        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 ); \
+        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8); \
+        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9); \
+        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10); \
+        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11); \
         \
-        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 ); \
-        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13 ); \
-        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 ); \
-        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 ); \
+        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12); \
+        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13); \
+        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14); \
+        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15); \
     
         PSIMAGESLICE_TEST(F32);
@@ -149,5 +149,5 @@
                            psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1),
                            PS_CUT_X_POS,
-                           stat );
+                           stat);
         ok(out == NULL, "psImageSlice() returned NULL with NULL input");
     
@@ -156,12 +156,12 @@
         // Following should be an error
         // XXX: Verify error
-        out = psImageSlice( out,
+        out = psImageSlice(out,
                             NULL, image,
                             mask, 1,
                             psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1),
                             PS_CUT_X_POS,
-                            NULL );
+                            NULL);
         ok(out == NULL, "psImageSlice() returned NULL with NULL psStats");
-            psError( PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
+            psError(PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected");
 
         // Verify the returned psVector structure pointer is null and program
@@ -182,5 +182,5 @@
         // Following should be an error
         // XXX: Verify error
-        out = psImageSlice( out,
+        out = psImageSlice(out,
                             NULL,
                             image,
@@ -188,5 +188,5 @@
                             psRegionSet(c/10, c/10, r/10, r/10),
                             PS_CUT_X_POS,
-                            stat );
+                            stat);
         ok(out == NULL, "psImageSlice() returned NULL with 0x0 region");
     
@@ -196,25 +196,25 @@
         // Following should be an error
         // XXX: Verify error
-        out = psImageSlice( out, NULL,
+        out = psImageSlice(out, NULL,
                             image,
                             mask, 1,
                             psRegionSet(c+1, c+2, r/10, r/10 + 10),
                             PS_CUT_X_POS,
-                            stat );
+                            stat);
         ok(out == NULL, "psImageSlice() returned NULL with unallowed x position");
     
         // Following should be an error
         // XXX: Verify error
-        out = psImageSlice( out, NULL,
+        out = psImageSlice(out, NULL,
                             image,
                             mask, 1,
                             psRegionSet(c/10, c/10 + 1, r+1,r+5),
                             PS_CUT_X_POS,
-                            stat );
+                            stat);
         ok(out == NULL, "psImageSlice() returned NULL with unallowed y position");
     
         // Following should be an error
         // XXX: Verify error
-        out = psImageSlice( out, NULL,
+        out = psImageSlice(out, NULL,
                             image,
                             mask, 1,
@@ -226,5 +226,5 @@
         // Following should be an error
         // XXX: Verify error
-        out = psImageSlice( out, NULL,
+        out = psImageSlice(out, NULL,
                             image,
                             mask, 1,
@@ -240,5 +240,5 @@
         // XXX: Verify error
         stat->options = 0;
-        out = psImageSlice( out, NULL,
+        out = psImageSlice(out, NULL,
                             image,
                             mask, 1,
@@ -253,6 +253,6 @@
         // XXX: Verify error
         stat->options = PS_STAT_SAMPLE_MEDIAN;
-        psImage* maskSz = psImageAlloc( r, c, PS_TYPE_MASK );
-        out = psImageSlice( out, NULL,
+        psImage* maskSz = psImageAlloc(r, c, PS_TYPE_MASK);
+        out = psImageSlice(out, NULL,
                             image,
                             maskSz, 1,
@@ -265,6 +265,6 @@
         // Following should be an error unallowed mask type
         // XXX: Verify error
-        psImage* maskS8 = psImageAlloc( c, r, PS_TYPE_S8 );
-        out =  psImageSlice( out, NULL,
+        psImage* maskS8 = psImageAlloc(c, r, PS_TYPE_S8);
+        out =  psImageSlice(out, NULL,
                              image,
                              maskS8, 1,
@@ -276,10 +276,10 @@
         //Added tests after subimage changes.
         psFree(image);
-        image = psImageAlloc( c, r, PS_TYPE_F64 );
-        for ( psS32 row = 0;row < r;row++ ) {
-            psF64 *imageRow = image->data.F64[ row ];
+        image = psImageAlloc(c, r, PS_TYPE_F64);
+        for (psS32 row = 0;row < r;row++) {
+            psF64 *imageRow = image->data.F64[row];
             psF64 rowOffset = row * 2;
-            for ( psS32 col = 0;col < c;col++ ) {
-                imageRow[ col ] = col + rowOffset;
+            for (psS32 col = 0;col < c;col++) {
+                imageRow[col] = col + rowOffset;
             }
         }
@@ -441,10 +441,10 @@
                     float y = (float)startRow[n]+(float)i*deltaRow;
                     if (n == 1) {
-//                        truth = psImagePixelInterpolate( image, x, y,
+//                        truth = psImagePixelInterpolate(image, x, y,
 //                                                         NULL,0,0,PS_INTERPOLATE_FLAT);
                           psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsNoMask);
                           truth = imgVal;
                     } else {
-//                        truth = psImagePixelInterpolate( image, x, y,
+//                        truth = psImagePixelInterpolate(image, x, y,
 //                                                         mask,1,0,PS_INTERPOLATE_FLAT);
                           psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsMask);
@@ -520,5 +520,5 @@
 
 
-    // testImageRadialCut()
+    // test psImageRadialCut()
     {
         psMemId id = psMemGetId();
@@ -557,5 +557,5 @@
                 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
                     diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)",
-                          result->data.F64[i], (15.0+i*10) );
+                          result->data.F64[i], (15.0+i*10));
                     errorFlag = true;
                 }
@@ -574,5 +574,5 @@
                 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
                     diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)",
-                          result->data.F64[i], (15.0+i*10) );
+                          result->data.F64[i], (15.0+i*10));
                     errorFlag = true;
                 }
@@ -709,17 +709,16 @@
         // Following should generate error message(for row)
         // XXX: Verify error
-        out = psImageRow(NULL, image, num);
+        out = psImageRow(NULL, NULL, num);
         ok(out == NULL, "psImageRow() returned NULL with NULL input image");
 
         // Following should generate error message(for col)
         // XXX: Verify error
-        out = psImageCol(NULL, image, num);
+        out = psImageCol(NULL, NULL, num);
         ok(out == NULL, "psImagecol() returned NULL with NULL input image");
-    
         image = psImageAlloc(3, 3, PS_TYPE_F64);
 
 
         //Test for unallowed row0.
-        *(psS32*)&(image->row0) = -1;
+        P_PSIMAGE_SET_ROW0(image, -2);
         // Following should generate error message(for row)
         // XXX: Verify error
@@ -810,4 +809,5 @@
     
         //Test valid cases.
+        //XXX: We do not verify the data values.
         P_PSIMAGE_SET_COL0(image, 10);
         P_PSIMAGE_SET_ROW0(image, 5);
@@ -875,5 +875,5 @@
     
         //Test for error with NULL image
-        empty = psImageCol(empty, emptyImage, 0);
+        empty = psImageCol(empty, NULL, 0);
         ok(empty == NULL, "psImageCol returned NULL for NULL image input");
         //Test for error with Out of Range Row
@@ -894,5 +894,5 @@
         test1 = fabs(rowcol->data.F64[0]-66.6);
         test2 = fabs(rowcol->data.F64[2]-666.66);
-        ok(!( (test1>TOLTST) || (test2>TOLTST)),
+        ok(!((test1>TOLTST) || (test2>TOLTST)),
            "psImageRow returned correct values");
         psFree(rowcol);
Index: trunk/psLib/test/imageops/tap_psImagePixelManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImagePixelManip.c	(revision 13084)
+++ trunk/psLib/test/imageops/tap_psImagePixelManip.c	(revision 13123)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-14 21:20:28 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-02 04:14:33 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -22,7 +22,7 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(47);
-
-    // testImageClip()
+    plan_tests(107);
+
+    // test psImageClip()
     {
         psMemId id = psMemGetId();
@@ -44,5 +44,5 @@
         // Verify the retuned integer is zero, psImage structure input is unmodified
         // and program executions doesn't stop, if input parameter psImage structure
-        // pointer is null.
+        // pointer is NULL.
         //
         // Verify the retuned integer is zero, psImage structure input is unmodified
@@ -111,5 +111,5 @@
         // Verify the retuned integer is zero, psImage structure input is unmodified
         // and program executions doesn't stop, if input parameter psImage structure
-        // pointer is null.
+        // pointer is NULL.
         retVal = psImageClip(NULL,min,-1.0f,max,-2.0f);
         ok(retVal == 0, "Expected zero return for clips of a NULL image");
@@ -144,5 +144,5 @@
         //
         // Verify the returned integer is zero and program execution doesn't stop,
-        // if the input parameter psImage structure pointer is null.
+        // if the input parameter psImage structure pointer is NULL.
         // create image
         #define testImageClipNaNByType(datatype) \
@@ -193,5 +193,5 @@
         // Verify the retuned integer is zero, psImage structure input is unmodified
         // and program executions doesn't stop, if input parameter psImage structure
-        // pointer is null.
+        // pointer is NULL.
         retVal = psImageClipNaN(NULL,-1.0f);
         ok(retVal == 0, "Expected zero return for clips of a NULL image");
@@ -286,11 +286,10 @@
         testOverlayTypeOP(DATATYPE,=,"=");
 
-
-        //        testOverlayType(F64);
-        //        testOverlayType(F32);
-        //        testOverlayType(S16);
-        //        testOverlayType(S8);
-        //        testOverlayType(U16);
-        //        testOverlayType(U8);
+        testOverlayType(F64);
+        testOverlayType(F32);
+        testOverlayType(S16);
+        testOverlayType(S8);
+        testOverlayType(U16);
+        testOverlayType(U8);
 
         // Verify the returned integer is equal to non-zero and the input psImage structure
@@ -351,5 +350,5 @@
         // Verify the returned integer is equal to non-zero, the input psImage
         // structure is unmodified and program execution doesn't stop, if the
-        // overlay specified is null.
+        // overlay specified is NULL.
         // Following should error as overlay is NULL
         // XXX: Verify error
@@ -371,5 +370,5 @@
 
         // Verify the returned integer is equal to non-zero and program execution
-        // doesn't stop, if the input parameter image is null.
+        // doesn't stop, if the input parameter image is NULL.
         // Following should error as image input is NULL
         // XXX: Verify error
@@ -416,34 +415,4 @@
         ok(retVal != 0, "psImageOverlaySection returned non-zero when checking divide-by-zero");
         errorFlag = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
         for (unsigned row=0;row<r;row++)
Index: trunk/psLib/test/imageops/tap_psImageStats.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageStats.c	(revision 13084)
+++ trunk/psLib/test/imageops/tap_psImageStats.c	(revision 13123)
@@ -273,23 +273,23 @@
     const int CHEBY_Y_DIM = 8;
     const int THRESHOLD = 1;
-    psImage *imgIn = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 );
-    psImage *imgOut = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 );
-    for (int i = 0;i < IMAGE_SIZE;i++ ) {
-        for (int j = 0;j < IMAGE_SIZE;j++ ) {
+    psImage *imgIn = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
+    psImage *imgOut = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
+    for (int i = 0;i < IMAGE_SIZE;i++) {
+        for (int j = 0;j < IMAGE_SIZE;j++) {
             imgIn->data.F32[ i ][ j ] = 4.0;
-            imgIn->data.F32[ i ][ j ] = ( float ) ( i + j );
-            imgIn->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i );
+            imgIn->data.F32[ i ][ j ] = (float) (i + j);
+            imgIn->data.F32[ i ][ j ] = (float) (i + j) + (4.0 * (float) i);
             imgOut->data.F32[ i ][ j ] = 0.0;
         }
     }
     psPolynomial2D *my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, CHEBY_X_DIM-1, CHEBY_Y_DIM-1);
-    my2DPoly = psImageFitPolynomial(my2DPoly, imgIn );
+    my2DPoly = psImageFitPolynomial(my2DPoly, imgIn);
     ok(my2DPoly != NULL, "psImageFitPolynomial() returned non-NULL");
 
-    imgOut = psImageEvalPolynomial( imgOut, my2DPoly );
+    imgOut = psImageEvalPolynomial(imgOut, my2DPoly);
     bool errorFlag = false;
-    for (int i = 0;i < IMAGE_SIZE;i++ ) {
-        for (int j = 0;j < IMAGE_SIZE;j++ ) {
-            if ( fabs( imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ] ) > THRESHOLD ) {
+    for (int i = 0;i < IMAGE_SIZE;i++) {
+        for (int j = 0;j < IMAGE_SIZE;j++) {
+            if (fabs(imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ]) > THRESHOLD) {
                 diag("Pixel (%d, %d) is %.2f, should be %.2f\n", i, j,
                      imgOut->data.F32[ i ][ j ],
@@ -357,5 +357,5 @@
         ok(hist2 == hist, "psImageHistogram() correctly recycled the input psHistogram");
         bool errorFlag = false;
-        for (int i = 0;i < numBins;i++ ) {
+        for (int i = 0;i < numBins;i++) {
             if (hist2->nums->data.F32[i] != (numCols * (numRows/numBins))) {
                 diag("ERROR: Bin number %d bounds: (%.1f - %.1f) data (%.2f)\n", i,
@@ -434,5 +434,5 @@
     }
 
-    // Ensure psImageCountPixelMask returns -1 for NULL input image
+    // Ensure psImageCountPixelMask returns -1 for wrong input image type
     // Following should generate error
     // XXX: Verify error
@@ -486,5 +486,5 @@
     // --------------------------------------------------------------
     // psImageStats()
-    // Ensure psImageStats() returnes NULL for NULL input image
+    // Ensure psImageStats() returns NULL for NULL input image
     // Following should generate error
     // XXX: Verify error
@@ -499,5 +499,5 @@
     }
 
-    // Ensure psImageStats() returnes NULL for NULL psStats
+    // Ensure psImageStats() returns NULL for NULL psStats
     // Following should generate error
     // XXX: Verify error
Index: trunk/psLib/test/imageops/tap_psImageStructManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageStructManip.c	(revision 13084)
+++ trunk/psLib/test/imageops/tap_psImageStructManip.c	(revision 13123)
@@ -1,11 +1,10 @@
-/** @file  tst_psImageExtraction.c
+/** @file  tap_psImageStructManip.c
 *
 *  @brief Contains the tests for psImageExtraction.[ch]
 *
-*
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-02-08 01:21:50 $
+*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-05-02 04:14:33 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -26,5 +25,4 @@
     // psImageSubset shall create child image of a specified size from a
     // parent psImage structure
-
     // psImageSubset()
     {
@@ -33,10 +31,9 @@
         psS32 c = 128;
         psS32 r = 256;
-        psRegion region1 = psRegionSet(0,c/2,0,r/2);
-        psRegion region2 = psRegionSet(c/4,c/4+c/2,r/4,r/4+r/2);
+        psRegion region1 = psRegionSet(0, c/2, 0, r/2);
+        psRegion region2 = psRegionSet(c/4, c/4+c/2, r/4, r/4+r/2);
 
         psImage* original = psImageAlloc(c,r,PS_TYPE_U32);
-        for (psS32 row=0;row<r;row++)
-        {
+        for (psS32 row=0;row<r;row++) {
             for (psS32 col=0;col<c;col++) {
                 original->data.F32[row][col] = row*1000+col;
@@ -63,6 +60,5 @@
 
         bool errorFlag = false;
-        for (psS32 row=0;row<r/2;row++)
-        {
+        for (psS32 row=0;row<r/2;row++) {
             for (psS32 col=0;col<c/2;col++) {
                 if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) {
@@ -99,5 +95,4 @@
         ok(subset2->children == NULL && subset3->children == NULL, "psImageSubset() set ->children correctly");
 
-
         // Verify the input psImage structure image only has the following members
         // changed: 1) Nchildren is increased by one. 2) parent contains pointer psImage structure
@@ -107,4 +102,5 @@
            "psImageSubset did properly store the children pointers.");
 
+
         // Verify the returned psImage structure pointer is null and program
         // execution doesn't stop, if the input parameter image is null.
@@ -114,4 +110,5 @@
         psImage* subset1 = psImageSubset(NULL,region1);
         ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL.");
+
 
         // Verify the returned psImage structure pointer is null and program
@@ -153,4 +150,5 @@
         ok(subset1 == NULL,
            "psImageSubset returned NULL when subset origin was outside of image (row0=-1)");
+
 
         // Verify the returned psImage structure pointer is null and program
@@ -205,33 +203,29 @@
         psU32 r = 256;
 
-        psImage* img = psImageAlloc(c,r,PS_TYPE_F32);
-        for (unsigned row=0;row<r;row++)
-        {
-            psF32* imgRow = img->data.F32[row];
+        psImage *img = psImageAlloc(c,r,PS_TYPE_F32);
+        for (unsigned row=0;row<r;row++) {
             for (unsigned col=0;col<c;col++) {
-                imgRow[col] = (psF32)(row+col);
-            }
-        }
-        psImage* img2 = psImageAlloc(c,r,PS_TYPE_F32);
-        for (unsigned row=0;row<r;row++)
-        {
-            psF32* img2Row = img2->data.F32[row];
+                img->data.F32[row][col] = (psF32)(row+col);
+            }
+        }
+        psImage *img2 = psImageAlloc(c,r,PS_TYPE_F32);
+        for (unsigned row=0;row<r;row++) {
             for (unsigned col=0;col<c;col++) {
-                img2Row[col] = 0.0f;
-            }
-        }
-
-        psImage* img3 = psImageCopy(img2,img,PS_TYPE_F32);
-        // Verify the returned psImage structure pointer is equal to the input parameter output.
+                img2->data.F32[row][col] = 0.0f;
+            }
+        }
+
+        psImage *img3 = psImageCopy(img2,img,PS_TYPE_F32);
+        // Verify the returned psImage structure pointer is equal to the input
+        // parameter output.
         ok(img2 == img3, "psImageCopy(): recycled input image");
 
-        // Verify the returned psImage structure is the same type as the input image structure
-        // if the specified output argument is NULL.
-        psImage* img4 = psImageCopy(NULL,img,PS_TYPE_F32);
+        // Verify the returned psImage structure is the same type as the input image
+        // structure if the specified output argument is NULL.
+        psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32);
         ok(img4 != NULL, "psImageCopy() returned non-NULL with NULL output argument");
         ok(img4->type.type == img->type.type, "psImageCopy() set the correct image type");
         bool errorFlag = false;
-        for (psU32 row=0;row<r;row++)
-        {
+        for (psU32 row=0;row<r;row++) {
             psF32* imgInRow = img->data.F32[row];
             psF32* imgOutRow = img4->data.F32[row];
@@ -326,14 +320,12 @@
         psS32 halfR = r/2;
         psS32 halfC = c/2;
-        psRegion centerHalf = {qtrC,qtrC+halfC,qtrR,qtrR+halfR};
+        psRegion centerHalf = {qtrC, qtrC+halfC, qtrR, qtrR+halfR};
 
         psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
-        for (psS32 row = 0; row < image->numRows; row++)
-        {
+        for (psS32 row = 0; row < image->numRows; row++) {
             for (psS32 col = 0; col < image->numCols; col++) {
                 image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f;
             }
         }
-
         // invoke psImageTrim with non-NULL image, and a valid region
         // x0,y0->x1,y1 (using only positive values). Verify that:
@@ -350,6 +342,5 @@
 
         bool errorFlag = false;
-        for (psS32 row = 0; row < image2->numRows; row++)
-        {
+        for (psS32 row = 0; row < image2->numRows; row++) {
             for (psS32 col = 0; col < image2->numCols; col++) {
                 if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC])
@@ -379,6 +370,5 @@
            image->numCols-qtrC, image->numRows-qtrR);
 
-        for (psS32 row = 0; row < image2->numRows; row++)
-        {
+        for (psS32 row = 0; row < image2->numRows; row++) {
             for (psS32 col = 0; col < image2->numCols; col++) {
                 if (fabsf(image2->data.F32[row][col] -
@@ -394,5 +384,6 @@
         ok(!errorFlag, "psImageTrim() set image data correctly");
 
-        //  4. invoke psImageTrim with x1<0, y1<0. Verify:
+
+        //  Invoke psImageTrim with x1<0, y1<0. Verify:
         //      a. the psImage size is (numCols+x1)-x0 by (numRows+y1)-y0.
         //      b. the pixel values coorespond to the region
@@ -405,7 +396,5 @@
            image2->numCols, image2->numRows,
            image->numCols-qtrC, image->numRows-qtrR);
-
-        for (psS32 row = 0; row < image2->numRows; row++)
-        {
+        for (psS32 row = 0; row < image2->numRows; row++) {
             for (psS32 col = 0; col < image2->numCols; col++) {
                 if (fabsf(image2->data.F32[row][col] -
@@ -422,5 +411,6 @@
         psFree(image1);
 
-        //  6. invoke psImageTrim with image=NULL Verify:
+
+        //  Invoke psImageTrim with image=NULL Verify:
         //      a. execution does not cease.
         //      b. return value is NULL
@@ -428,6 +418,4 @@
         // An error should follow...
         // XXX: Verify errors
-
-
         image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0));
         ok(image2 == NULL, "psImageTrim returned NULL given a NULL input image");
@@ -438,4 +426,5 @@
 
 
+        // Verify when psRegion has a coord at -1
         image1 = psImageCopy(NULL,image,PS_TYPE_F32);
         image2 = psImageTrim(image1, psRegionSet(-1,0,0,0));
@@ -447,4 +436,5 @@
 
 
+        // Verify when psRegion has a coord at -1
         image1 = psImageCopy(NULL,image,PS_TYPE_F32);
         image2 = psImageTrim(image1, psRegionSet(0,0,-1,0));
@@ -456,4 +446,5 @@
 
 
+        // Verify when psRegion has a coord at outside the image range
         image1 = psImageCopy(NULL,image,PS_TYPE_F32);
         image2 = psImageTrim(image1, psRegionSet(0,image->numCols+1,0,0));
@@ -465,4 +456,5 @@
 
 
+        // Verify when psRegion has a coord at outside the image range
         image1 = psImageCopy(NULL,image,PS_TYPE_F32);
         image2 = psImageTrim(image1, psRegionSet(0,0,0,image->numRows+1));
@@ -474,4 +466,5 @@
 
 
+        // Verify when psRegion has a coord at outside the image range
         image1 = psImageCopy(NULL,image,PS_TYPE_F32);
         image2 = psImageTrim(image1, psRegionSet(0,0,0,(((psF32)image->numRows)*-1.0)));
@@ -483,4 +476,5 @@
 
 
+        // Verify when psRegion has a coord at outside the image range
         image1 = psImageCopy(NULL,image,PS_TYPE_F32);
         image2 = psImageTrim(image1, psRegionSet(0,(((psF32)image->numCols)*-1.0),0,0));
Index: trunk/psLib/test/math/Makefile.am
===================================================================
--- trunk/psLib/test/math/Makefile.am	(revision 13084)
+++ trunk/psLib/test/math/Makefile.am	(revision 13123)
@@ -47,5 +47,9 @@
 	tap_psStatsTiming \
 	tap_psFunc01 \
-	tap_psStats_Sample_01
+	tap_psStats_Sample_01 \
+	tap_psMatrixVectorArithmetic01 \
+	tap_psMatrixVectorArithmetic04 \
+	tap_psRandom \
+	tap_psMinimizePowell
 
 if BUILD_TESTS
Index: trunk/psLib/test/math/tap_psMatrix03.c
===================================================================
--- trunk/psLib/test/math/tap_psMatrix03.c	(revision 13084)
+++ trunk/psLib/test/math/tap_psMatrix03.c	(revision 13123)
@@ -16,6 +16,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2006-12-20 20:02:29 $
+ *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-05-02 04:14:33 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -184,5 +184,6 @@
 
     // Attempt to use null image input argument
-    // XXX: This test should generate an error or warning, but we don't know how to test that.
+    // XXX: This test should generate an error or warning
+    // XXX: This seg-faults
     if (0) {
         psMemId id = psMemGetId();
@@ -195,5 +196,6 @@
 
     // Attempt to use null input vector argument
-    // XXX: This test should generate an error or warning, but we don't know how to test that.
+    // XXX: This test should generate an error or warning
+    // XXX: This seg-faulta
     if (0) {
         psMemId id = psMemGetId();
@@ -212,4 +214,5 @@
     // Attempt to use null LU image argument
     // XXX: This test should generate an error or warning, but we don't know how to test that.
+    // XXX: This seg-faulta
     if (0) {
         psMemId id = psMemGetId();
Index: trunk/psLib/test/math/tap_psMatrixVectorArithmetic01.c
===================================================================
--- trunk/psLib/test/math/tap_psMatrixVectorArithmetic01.c	(revision 13084)
+++ trunk/psLib/test/math/tap_psMatrixVectorArithmetic01.c	(revision 13123)
@@ -10,6 +10,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-14 00:39:51 $
+ *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-05-02 04:14:33 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -128,5 +128,5 @@
     bool errorFlag = false;
     bool memoryFlag = false;
-    plan_tests(90);
+    plan_tests(72);
 
     //Test matrix-matrix binary operations
Index: trunk/psLib/test/math/tap_psMatrixVectorArithmetic02.c
===================================================================
--- trunk/psLib/test/math/tap_psMatrixVectorArithmetic02.c	(revision 13084)
+++ trunk/psLib/test/math/tap_psMatrixVectorArithmetic02.c	(revision 13123)
@@ -10,6 +10,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-14 00:39:51 $
+ *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-05-02 04:14:33 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -18,4 +18,5 @@
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include <pslib.h>
 #include "tap.h"
Index: trunk/psLib/test/math/tap_psMatrixVectorArithmetic03.c
===================================================================
--- trunk/psLib/test/math/tap_psMatrixVectorArithmetic03.c	(revision 13084)
+++ trunk/psLib/test/math/tap_psMatrixVectorArithmetic03.c	(revision 13123)
@@ -15,6 +15,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2007-03-14 00:39:51 $
+ *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2007-05-02 04:14:33 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -68,5 +68,5 @@
     // Check for NULL input argument #1
 
-    if (0) {
+    if (1) {
         psMemId id = psMemGetId();
         psImage* image6 = (psImage*)psBinaryOp(image6, NULL, "+", image2);
@@ -249,5 +249,4 @@
     psFree(image3);
     psFree(image4);
-    psFree(image5);
     psFree(vector1);
     psFree(vector2);
Index: trunk/psLib/test/math/tap_psMinimizePowell.c
===================================================================
--- trunk/psLib/test/math/tap_psMinimizePowell.c	(revision 13084)
+++ trunk/psLib/test/math/tap_psMinimizePowell.c	(revision 13123)
@@ -74,5 +74,5 @@
 {
     psLogSetFormat("HLNM");
-    plan_tests(2);
+    plan_tests(1);
 
     // Check for various errors on unallowed input parameters
@@ -134,5 +134,5 @@
 
     // Powell minimize with parameter mask
-    {
+    if (0) {
         psMemId id = psMemGetId();
         psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
@@ -186,5 +186,5 @@
     // Powell minimize with parameter mask
     // The only difference from the previous block is that paramMask is now NULL
-    {
+    if (0) {
         psMemId id = psMemGetId();
         psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32);
Index: trunk/psLib/test/math/tap_psRandom.c
===================================================================
--- trunk/psLib/test/math/tap_psRandom.c	(revision 13084)
+++ trunk/psLib/test/math/tap_psRandom.c	(revision 13123)
@@ -47,5 +47,4 @@
     plan_tests(34);
 
-    diag("ensure that psRandom structs are properly allocated by psRandomAlloc()");
     // ensure that psRandom structs are properly allocated by psRandomAlloc()
     {
@@ -81,5 +80,5 @@
     // testRandomUniform(void)
     {
-        diag("testRandomUniform()");
+        // testRandomUniform()
         psMemId id = psMemGetId();
         psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
@@ -91,13 +90,12 @@
 
         // Initialize vector data with random number
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans->data.F64[i] = psRandomUniform(myRNG);
         }
 
         // Perform vector stats on random data (mean, stdev)
-        stats = psVectorStats(stats, rans, NULL, NULL, 0);
+        psVectorStats(stats, rans, NULL, NULL, 0);
         stats->options = PS_STAT_SAMPLE_STDEV;
-        stats = psVectorStats(stats, rans, NULL, NULL, 0);
+        psVectorStats(stats, rans, NULL, NULL, 0);
 
         // Verify mean and stdev
@@ -132,13 +130,12 @@
 
         // Initialize vector with random data
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans->data.F64[i] = psRandomGaussian(myRNG);
         }
 
         // Perform vector stats on data (mean, stdev)
-        stats = psVectorStats(stats, rans, NULL, NULL, 0);
+        psVectorStats(stats, rans, NULL, NULL, 0);
         stats->options = PS_STAT_SAMPLE_STDEV;
-        stats = psVectorStats(stats, rans, NULL, NULL, 0);
+        psVectorStats(stats, rans, NULL, NULL, 0);
 
         // Verify mean and stdev
@@ -175,13 +172,12 @@
 
         // Initialize vector with random data
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
         }
 
         // Perform vector stats on random data (mean, stdev)
-        stats = psVectorStats(stats, rans, NULL, NULL, 0);
+        psVectorStats(stats, rans, NULL, NULL, 0);
         stats->options = PS_STAT_SAMPLE_STDEV;
-        stats = psVectorStats(stats, rans, NULL, NULL, 0);
+        psVectorStats(stats, rans, NULL, NULL, 0);
         // Verify mean and stdev
         is_float_tol_per(stats->sampleMean, POISSON_MEAN, ERROR_TOLERANCE, "Mean is within expected range");
@@ -221,16 +217,13 @@
         // Random reset
         psRandomReset(myRNG, SEED);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans00->data.F64[i] = psRandomUniform(myRNG);
         }
         psRandomReset(myRNG, SEED2);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans01->data.F64[i] = psRandomUniform(myRNG);
         }
         psRandomReset(myRNG, SEED);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans02->data.F64[i] = psRandomUniform(myRNG);
         }
@@ -273,5 +266,5 @@
     // testRandomResetGaussian(void)
     {
-        diag("testRandomGaussian(): ensure the seed resets properly");
+        // testRandomGaussian(): ensure the seed resets properly
         psMemId id = psMemGetId();
         psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
@@ -289,16 +282,13 @@
         // Initialize random data in vectors
         psRandomReset(myRNG, SEED);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans00->data.F64[i] = psRandomGaussian(myRNG);
         }
         psRandomReset(myRNG, SEED2);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans01->data.F64[i] = psRandomGaussian(myRNG);
         }
         psRandomReset(myRNG, SEED);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans02->data.F64[i] = psRandomGaussian(myRNG);
         }
@@ -306,6 +296,5 @@
         // Verify data from original seed produces same data after reset
         psBool errorFlag = false;
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             if (rans00->data.F64[i] != rans02->data.F64[i]) {
                 if (VERBOSE) {
@@ -315,5 +304,5 @@
             }
         }
-        ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
+        ok(!errorFlag, "psRandomGaussian() produced the same results with the same seed");
         skip_end();
         psFree(myRNG);
@@ -342,16 +331,13 @@
         // Initialize vectors with random data
         psRandomReset(myRNG, SEED);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
         }
         psRandomReset(myRNG, SEED2);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
         }
         psRandomReset(myRNG, SEED);
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
         }
@@ -359,6 +345,5 @@
         // Verify the original seed produces same data after reset
         psBool errorFlag = false;
-        for (psS32 i = 0 ; i < NUM_DATA ; i++)
-        {
+        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
             if (rans00->data.F64[i] != rans02->data.F64[i]) {
                 if (VERBOSE) {
@@ -368,5 +353,5 @@
             }
         }
-        ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
+        ok(!errorFlag, "psRandomPoisson() produced the same results with the same seed");
         skip_end();
         psFree(myRNG);
Index: trunk/psLib/test/math/tap_psSparse.c
===================================================================
--- trunk/psLib/test/math/tap_psSparse.c	(revision 13084)
+++ trunk/psLib/test/math/tap_psSparse.c	(revision 13123)
@@ -10,11 +10,9 @@
     plan_tests(26);
 
-//    diag("psSparse() tests");
-
     // test psSparseSolve for a simple normal example matrix
     {
         psMemId id = psMemGetId();
 
-//        diag ("solve a normalized matrix equation with psSparseSolve");
+        //solve a normalized matrix equation with psSparseSolve
 
         // the basic equation is Ax = b
@@ -28,6 +26,5 @@
         skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
 
-        for (int i = 0; i < 100; i++)
-        {
+        for (int i = 0; i < 100; i++) {
             psSparseMatrixElement (matrix, i, i, 1.0);
             if (i + 1 < 100) {
@@ -38,5 +35,5 @@
         // incoming matrix elements do not need to be in order; sort before
         // applying sparse matrix
-        psSparseResort (matrix);
+        psSparseResort(matrix);
 
         psVector *xRef = psVectorAlloc (100, PS_TYPE_F32);
@@ -46,9 +43,8 @@
         }
 
-        psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef);
-
-        for (int i = 0; i < 100; i++)
-        {
-            psSparseVectorElement (matrix, i, bVec->data.F32[i]);
+        psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef);
+
+        for (int i = 0; i < 100; i++) {
+            psSparseVectorElement(matrix, i, bVec->data.F32[i]);
         }
 
@@ -59,5 +55,5 @@
 
         // solve for normalization terms (need include local sky?)
-        psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);
+        psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4);
 
         // measure stdev between xFit and xRes
@@ -89,8 +85,6 @@
         psMemId id = psMemGetId();
 
-//        diag ("solve a non-normalized matrix equation with psSparseSolve");
-
+        //solve a non-normalized matrix equation with psSparseSolve
         // the basic equation is Ax = b
-
         // create a matrix A with diagonals of 1 and a small number of off diagonal elements.
         // construct a vector x, construct the corresponding vector b by multiplication. solve
@@ -101,6 +95,5 @@
         skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
 
-        for (int i = 0; i < 100; i++)
-        {
+        for (int i = 0; i < 100; i++) {
             psSparseMatrixElement (matrix, i, i, 5.0);
             if (i + 1 < 100) {
@@ -111,5 +104,5 @@
         // incoming matrix elements do not need to be in order; sort before
         // applying sparse matrix
-        psSparseResort (matrix);
+        psSparseResort(matrix);
 
         psVector *xRef = psVectorAlloc (100, PS_TYPE_F32);
@@ -119,9 +112,8 @@
         }
 
-        psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef);
-
-        for (int i = 0; i < 100; i++)
-        {
-            psSparseVectorElement (matrix, i, bVec->data.F32[i]);
+        psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef);
+
+        for (int i = 0; i < 100; i++) {
+            psSparseVectorElement(matrix, i, bVec->data.F32[i]);
         }
 
@@ -132,5 +124,5 @@
 
         // solve for normalization terms (need include local sky?)
-        psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);
+        psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4);
 
         // measure stdev between xFit and xRes
@@ -173,5 +165,5 @@
         psMemId id = psMemGetId();
 
-//        diag ("solve a simple, small matrix equation ");
+        //solve a simple, small matrix equation
 
         // the basic equation (Ax = b) is:
@@ -192,8 +184,8 @@
         skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
 
-        psSparseMatrixElement (matrix, 0, 0, 1.0);
-        psSparseMatrixElement (matrix, 1, 1, 1.0);
-        psSparseMatrixElement (matrix, 1, 0, 0.1);
-        psSparseResort (matrix);
+        psSparseMatrixElement(matrix, 0, 0, 1.0);
+        psSparseMatrixElement(matrix, 1, 1, 1.0);
+        psSparseMatrixElement(matrix, 1, 0, 0.1);
+        psSparseResort(matrix);
 
         // border region has a width of 1:
@@ -244,11 +236,9 @@
 
         // supply the fVec and gVec data to the border
-        for (int i = 0; i < Nrows; i++)
-        {
-            psSparseVectorElement (border->sparse, i, fVec->data.F32[i]);
-        }
-        for (int i = 0; i < Nborder; i++)
-        {
-            psSparseBorderElementG (border, i, gVec->data.F32[i]);
+        for (int i = 0; i < Nrows; i++) {
+            psSparseVectorElement(border->sparse, i, fVec->data.F32[i]);
+        }
+        for (int i = 0; i < Nborder; i++) {
+            psSparseBorderElementG(border, i, gVec->data.F32[i]);
         }
 
@@ -262,5 +252,5 @@
         psVector *xFit = NULL;
         psVector *yFit = NULL;
-        psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);
+        psSparseBorderSolve(&xFit, &yFit, constraint, border, 4);
         is_float_tol (xFit->data.F32[0], 1.0, 1e-4, "f(0): %f", xFit->data.F32[0]);
         is_float_tol (xFit->data.F32[1], 1.0, 1e-4, "f(1): %f", xFit->data.F32[1]);
@@ -283,5 +273,5 @@
         psMemId id = psMemGetId();
 
-//        diag ("solve a simple, small matrix equation ");
+        // solve a simple, small matrix equation
 
         // the basic equation (Ax = b) is:
@@ -302,12 +292,11 @@
         skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed");
 
-        for (int i = 0; i < Nrows; i++)
-        {
-            psSparseMatrixElement (matrix, i, i, 1.0);
+        for (int i = 0; i < Nrows; i++) {
+            psSparseMatrixElement(matrix, i, i, 1.0);
             if (i + 1 < Nrows) {
-                psSparseMatrixElement (matrix, i + 1, i, 0.1);
-            }
-        }
-        psSparseResort (matrix);
+                psSparseMatrixElement(matrix, i + 1, i, 0.1);
+            }
+        }
+        psSparseResort(matrix);
 
         // border region has a width of 1:
@@ -349,11 +338,9 @@
 
         // supply the fVec and gVec data to the border
-        for (int i = 0; i < Nrows; i++)
-        {
-            psSparseVectorElement (border->sparse, i, fVec->data.F32[i]);
-        }
-        for (int i = 0; i < Nborder; i++)
-        {
-            psSparseBorderElementG (border, i, gVec->data.F32[i]);
+        for (int i = 0; i < Nrows; i++) {
+            psSparseVectorElement(border->sparse, i, fVec->data.F32[i]);
+        }
+        for (int i = 0; i < Nborder; i++) {
+            psSparseBorderElementG(border, i, gVec->data.F32[i]);
         }
 
@@ -367,5 +354,5 @@
         psVector *xFit = NULL;
         psVector *yFit = NULL;
-        psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);
+        psSparseBorderSolve(&xFit, &yFit, constraint, border, 4);
 
         // measure stdev between xFit and xRef
Index: trunk/psLib/test/mathtypes/tap_psVector.c
===================================================================
--- trunk/psLib/test/mathtypes/tap_psVector.c	(revision 13084)
+++ trunk/psLib/test/mathtypes/tap_psVector.c	(revision 13123)
@@ -8,4 +8,6 @@
 int main (void)
 {
+    psLogSetFormat("HLNM");
+    psLogSetLevel(PS_LOG_INFO);
     plan_tests(285);
 
@@ -626,5 +628,5 @@
         vec->data.U8[4] = 0;
         long numPix = psVectorCountPixelMask(vec, 1);
-        ok(numPix != -1, "returned -1 for correct Vector input");
+        ok(numPix != -1, "did not return -1 for correct Vector input");
         ok(numPix == 2, "returned pixel count %d", numPix);
         psFree(vec);
Index: trunk/psLib/test/types/tap_psPixels_all.c
===================================================================
--- trunk/psLib/test/types/tap_psPixels_all.c	(revision 13084)
+++ trunk/psLib/test/types/tap_psPixels_all.c	(revision 13123)
@@ -23,6 +23,5 @@
     plan_tests(36);
 
-    note("Tests for psPixels Functions");
-
+    //Tests for psPixels Functions
     testPixelsCreate();
     testPixelsManip();
@@ -33,6 +32,5 @@
 void testPixelsCreate(void)
 {
-    note("  >>>Test 1:  psPixels Creation Fxns");
-
+    //Test 1:  psPixels Creation Fxns
     //Return allocated psPixels of length 0 with NULL data.
     psPixels* p0 = psPixelsAlloc(0);
@@ -49,5 +47,5 @@
     //Make sure psMemCheckPixels works correctly - return true
     {
-        ok( psMemCheckPixels(p1),
+        ok(psMemCheckPixels(p1),
             "psMemCheckPixels:      return true for psPixels input.");
     }
@@ -55,5 +53,5 @@
     {
         int j = 2;
-        ok( !psMemCheckPixels(&j),
+        ok(!psMemCheckPixels(&j),
             "psMemCheckPixels:      return false for non-psPixels input.");
     }
@@ -62,5 +60,5 @@
         psPixels *noPix = psPixelsAlloc(1);
         noPix = psPixelsRealloc(noPix, 0);
-        ok( noPix->n == 0 && noPix->nalloc == 0,
+        ok(noPix->n == 0 && noPix->nalloc == 0,
             "psPixelsRealloc:       return re-allocated psPixels of 0 length.");
         psFree(noPix);
@@ -75,5 +73,5 @@
                      "Skipping 1 tests because psPixels input is of wrong size! =%ld", p0->n);
         p0 = psPixelsRealloc(p0, 2);
-        ok( p0->n == 2 && fabs(p0->data[0].x - 1.1) < FLT_EPSILON && p0->nalloc == 2,
+        ok(p0->n == 2 && fabs(p0->data[0].x - 1.1) < FLT_EPSILON && p0->nalloc == 2,
             "psPixelsRealloc:       return properly down-sized psPixels.");
         skip_end();
@@ -83,5 +81,5 @@
         psPixels *noPix = NULL;
         noPix = psPixelsCopy(noPix, p0);
-        ok( noPix->n == 2 && fabs(noPix->data[0].x - 1.1) < FLT_EPSILON && noPix->nalloc == 2,
+        ok(noPix->n == 2 && fabs(noPix->data[0].x - 1.1) < FLT_EPSILON && noPix->nalloc == 2,
             "psPixelsCopy:          return properly copied psPixels.");
         psFree(noPix);
@@ -91,5 +89,5 @@
         psPixels *noPix = NULL;
         noPix = psPixelsCopy(noPix, NULL);
-        ok( noPix == NULL,
+        ok(noPix == NULL,
             "psPixelsCopy:          return NULL for NULL psPixels input.");
     }
@@ -105,6 +103,5 @@
 void testPixelsManip(void)
 {
-    note("  >>>Test 2:  psPixels Manipulation Fxns");
-
+    //psPixels Manipulation Fxns
     //Tests for psPixelsSet
     psPixels *p0 = psPixelsAlloc(1);
@@ -114,30 +111,30 @@
     //Return false for NULL pixels input
     {
-        ok( !psPixelsSet(NULL, 0, in),
+        ok(!psPixelsSet(NULL, 0, in),
             "psPixelsSet:          return false for NULL pixels input.");
     }
     //Return true for valid inputs
     {
-        ok( psPixelsSet(p0, 0, in),
+        ok(psPixelsSet(p0, 0, in),
             "psPixelsSet:          return true for valid inputs.");
     }
     //Return false for position == nalloc
     {
-        ok( !psPixelsSet(p0, 1, in),
+        ok(!psPixelsSet(p0, 1, in),
             "psPixelsSet:          return false for position == nalloc.");
     }
     //Return false for out-of-range position
     {
-        ok( !psPixelsSet(p0, 2, in),
+        ok(!psPixelsSet(p0, 2, in),
             "psPixelsSet:          return false for out-of-range position.");
     }
     //Return false for negative out-of-range position
     {
-        ok( !psPixelsSet(p0, -2, in),
+        ok(!psPixelsSet(p0, -2, in),
             "psPixelsSet:          return false for negative out-of-range position.");
     }
     //Return true for valid negative position
     {
-        ok( psPixelsSet(p0, -1, in),
+        ok(psPixelsSet(p0, -1, in),
             "psPixelsSet:          return true for valid negative position.");
     }
@@ -148,5 +145,5 @@
     {
         out = psPixelsGet(NULL, 1);
-        ok( isnan(out.x) &&  isnan(out.y),
+        ok(isnan(out.x) &&  isnan(out.y),
             "psPixelsGet:          return NANs for NULL pixels input.");
     }
@@ -154,5 +151,5 @@
     {
         out = psPixelsGet(p0, 2);
-        ok( isnan(out.x) &&  isnan(out.y),
+        ok(isnan(out.x) &&  isnan(out.y),
             "psPixelsGet:          return NANs for out-of-range position.");
     }
@@ -160,5 +157,5 @@
     {
         out = psPixelsGet(p0, -2);
-        ok( isnan(out.x) &&  isnan(out.y),
+        ok(isnan(out.x) &&  isnan(out.y),
             "psPixelsGet:          return NANs for out-of-range negative position.");
     }
@@ -166,5 +163,5 @@
     {
         out = psPixelsGet(p0, 0);
-        ok( fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
+        ok(fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
             "psPixelsGet:          return correct values for valid inputs.");
     }
@@ -172,5 +169,5 @@
     {
         out = psPixelsGet(p0, -1);
-        ok( fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
+        ok(fabs(out.x - 1.1) < FLT_EPSILON &&  fabs(out.y - 1.2) < FLT_EPSILON,
             "psPixelsGet:          return correct values for valid negative position.");
     }
@@ -180,5 +177,5 @@
     {
         FILE *newFD = fopen("psPixels.out", "w+");
-        ok ( p_psPixelsPrint(newFD, p0, "PS-PIXELS"),
+        ok(p_psPixelsPrint(newFD, p0, "PS-PIXELS"),
              "p_psPixelsPrint:      return true for valid input.");
         fflush(NULL);
@@ -188,5 +185,5 @@
     {
         FILE *dummy = fopen("psPixels.out", "r");
-        ok ( !p_psPixelsPrint(dummy, p0, "failed test"),
+        ok(!p_psPixelsPrint(dummy, p0, "failed test"),
              "p_psPixelsPrint:      return false for invalid file input.");
         fclose(dummy);
@@ -196,5 +193,5 @@
     //Return false for NULL pixels and name inputs
     {
-        ok ( !p_psPixelsPrint(stdout, NULL, NULL),
+        ok(!p_psPixelsPrint(stdout, NULL, NULL),
              "p_psPixelsPrint:      return false for NULL pixels and name inputs.");
     }
@@ -202,8 +199,10 @@
     psPixels *p1 = psPixelsAlloc(0);
     {
-        ok ( p_psPixelsPrint(NULL, p1, "noPix"),
+        ok(p_psPixelsPrint(NULL, p1, "noPix"),
              "p_psPixelsPrint:      return true for NULL file and empty pixel data inputs.");
     }
 
+
+    //----------------------------------------------------------------------
     //psPixelsToMask Tests
     psImage *outImage = NULL;
@@ -214,54 +213,71 @@
     region.y1 = 5.0;
     psMaskType maskVal = 1;
-
     //Return NULL for NULL pixels input
     {
+        psMemId id = psMemGetId();
         outImage = psPixelsToMask(outImage, NULL, region, maskVal);
-        ok ( outImage == NULL,
-             "psPixelsToMask:       return NULL for NULL pixels input.");
-    }
+        ok(outImage == NULL, "psPixelsToMask: return NULL for NULL pixels input.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for empty pixel data
     {
+        psMemId id = psMemGetId();
         outImage = psPixelsToMask(outImage, p1, region, maskVal);
-        ok ( outImage == NULL,
-             "psPixelsToMask:       return NULL for NULL pixels data input.");
-    }
+        ok(outImage == NULL, "psPixelsToMask: return NULL for NULL pixels data input.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for bad region input - negative value
     {
+        psMemId id = psMemGetId();
         outImage = psPixelsToMask(outImage, p0, region, maskVal);
-        ok ( outImage == NULL,
-             "psPixelsToMask:       return NULL for negative value in region.");
-    }
+        ok(outImage == NULL, "psPixelsToMask: return NULL for negative value in region.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return NULL for bad region input - upper bound less than lower bound
     region.x0 = 3.0;
     region.x1 = 1.0;
     {
+        psMemId id = psMemGetId();
         outImage = psPixelsToMask(outImage, p0, region, maskVal);
-        ok ( outImage == NULL,
-             "psPixelsToMask:       return NULL for bad region input.");
-    }
+        ok(outImage == NULL, "psPixelsToMask: return NULL for bad region input.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //Return NULL for un-recyclable image - out->type.dimen != PS_DIMEN_IMAGE
     region.x0 = 1.0;
     region.x1 = 3.0;
-    //Return NULL for un-recyclable image - out->type.dimen != PS_DIMEN_IMAGE
     outImage = psImageAlloc(1, 1, PS_TYPE_S32);
     *(psDimen*)&(outImage->type.dimen) = PS_DIMEN_OTHER;
     {
+        psMemId id = psMemGetId();
         outImage = psPixelsToMask(outImage, p0, region, maskVal);
-        ok ( outImage == NULL,
-             "psPixelsToMask:       return NULL for bad image input.");
-    }
+        ok(outImage == NULL, "psPixelsToMask: return NULL for bad image input.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
     //Return valid image for valid inputs
+    //XXX: Musr check pixel values
     p0 = psPixelsAdd(p0, 1, 2.1, 2.2);
     p0 = psPixelsAdd(p0, 1, 3.1, 3.2);
     p0 = psPixelsAdd(p0, 1, 1.0, 1.0);
     {
+        psMemId id = psMemGetId();
         outImage = psPixelsToMask(outImage, p0, region, maskVal);
-        ok ( outImage != NULL,
-             "psPixelsToMask:       return valid image for valid input.");
-    }
-
+        ok(outImage != NULL, "psPixelsToMask: return valid image for valid input.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+    psFree(outImage);
+
+
+    //----------------------------------------------------------------------
     //psPixelsFromMask Tests
-    //Return valid psPixels for valid inputs
-    psFree(outImage);
     outImage = psImageAlloc(31, 99, PS_TYPE_MASK);
     for (int i = 0; i < outImage->numCols; i++) {
@@ -270,37 +286,48 @@
         }
     }
-
-    {
+    //Return valid psPixels for valid inputs
+    //XXX: We never check output psPixels
+    {
+        psMemId id = psMemGetId();
         psPixels *outPixels = NULL;
         outPixels = psPixelsFromMask(outPixels, outImage, maskVal);
-        ok ( outPixels != NULL,
-             "psPixelsFromMask:     return valid pixels for valid input.");
+        ok(outPixels != NULL, "psPixelsFromMask: return valid pixels for valid input.");
         psFree(outPixels);
-    }
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     // Return NULL for NULL image input
     {
+        psMemId id = psMemGetId();
         psPixels *outPixels = NULL;
         outPixels = psPixelsFromMask(outPixels, NULL, maskVal);
-        ok ( outPixels == NULL,
-             "psPixelsFromMask:     return NULL for NULL image input.");
-    }
+        ok(outPixels == NULL, "psPixelsFromMask: return NULL for NULL image input.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     // Return NULL for image with wrong maskType
-    *(psElemType*)&(outImage->type.type) = PS_TYPE_U32;
-    {
+    {
+        *(psElemType*)&(outImage->type.type) = PS_TYPE_U32;
+        psMemId id = psMemGetId();
         psPixels *outPixels = NULL;
         outPixels = psPixelsFromMask(outPixels, outImage, maskVal);
-        ok ( outPixels == NULL,
-             "psPixelsFromMask:     return NULL for image with wrong maskType.");
-    }
-
+        ok(outPixels == NULL, "psPixelsFromMask: return NULL for image with wrong maskType.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+        *(psElemType*)&(outImage->type.type) = PS_TYPE_U8;
+    }
+
+
+
+    //----------------------------------------------------------------------
     // psPixelsConcatenate Tests
     // Return NULL for NULL pixels input
     {
+        psMemId id = psMemGetId();
         psPixels *outPixels = NULL;
         outPixels = psPixelsConcatenate(outPixels, NULL);
-        ok ( outPixels == NULL,
-             "psPixelsConcatenate:  return NULL for NULL pixels input.");
+        ok(outPixels == NULL, "psPixelsConcatenate: return NULL for NULL pixels input.");
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
     }
 
@@ -308,54 +335,57 @@
     //Return copy of input pixels for NULL out pixels
     {
+        psMemId id = psMemGetId();
         psPixels *outPixels = NULL;
         outPixels = psPixelsFromMask(outPixels, outImage, maskVal);
         outPixels = psPixelsConcatenate(outPixels, p0);
-        ok ( outPixels->n == 4 && fabs(outPixels->data[0].x - 1.1) < FLT_EPSILON &&
+        ok(outPixels->n == 4 && fabs(outPixels->data[0].x - 1.1) < FLT_EPSILON &&
              fabs(outPixels->data[0].y - 1.2) < FLT_EPSILON ,
              "psPixelsConcatenate:  return copy of input pixels for NULL out input.");
         psFree(outPixels);
-    }
-
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //test psPixelsConcatenate()
     //Return properly concatenated psPixels list
-    //Set all the compare cases to cover 'comparePixelCoord' as well.
-    psPixels *outPixels = psPixelsAlloc(5);
-    in.x = 1.0;
-    in.y = 1.0;
-    psPixelsSet(outPixels, 0, in);  //1, 1
-    psPixelsSet(outPixels, 1, in);  //1, 1
-    in.y = 2.0;
-    psPixelsSet(outPixels, 2, in);  //1, 2
-    in.y = 1.0;
-    psPixelsSet(outPixels, 3, in);  //1, 1
-    in.x = 2.0;
-    psPixelsSet(outPixels, 4, in);  //2, 1
-
-    psPixels *testPixels = psPixelsAlloc(6);
-    in.x = 1.0;
-    in.y = 1.0;
-    psPixelsSet(testPixels, 0, in);  //1, 1
-    in.y = 2.0;
-    psPixelsSet(testPixels, 1, in);  //1, 2
-    in.y = 1.0;
-    psPixelsSet(testPixels, 2, in);  //1, 1
-    in.x = 2.0;
-    psPixelsSet(testPixels, 3, in);  //2, 1
-    in.x = 1.0;
-    psPixelsSet(testPixels, 4, in);  //1, 1
-    in.x = 5.0;
-    in.y = 3.0;
-    psPixelsSet(testPixels, 5, in);  //5, 3
-    //Return properly concatenate pixel list
-    {
+    {
+        psMemId id = psMemGetId();
+        psPixels *outPixels = psPixelsAlloc(5);
+        in.x = 1.0;
+        in.y = 1.0;
+        psPixelsSet(outPixels, 0, in);  //1, 1
+        psPixelsSet(outPixels, 1, in);  //1, 1
+        in.y = 2.0;
+        psPixelsSet(outPixels, 2, in);  //1, 2
+        in.y = 1.0;
+        psPixelsSet(outPixels, 3, in);  //1, 1
+        in.x = 2.0;
+        psPixelsSet(outPixels, 4, in);  //2, 1
+        psPixels *testPixels = psPixelsAlloc(6);
+        in.x = 1.0;
+        in.y = 1.0;
+        psPixelsSet(testPixels, 0, in);  //1, 1
+        in.y = 2.0;
+        psPixelsSet(testPixels, 1, in);  //1, 2
+        in.y = 1.0;
+        psPixelsSet(testPixels, 2, in);  //1, 1
+        in.x = 2.0;
+        psPixelsSet(testPixels, 3, in);  //2, 1
+        in.x = 1.0;
+        psPixelsSet(testPixels, 4, in);  //1, 1
+        in.x = 5.0;
+        in.y = 3.0;
+        psPixelsSet(testPixels, 5, in);  //5, 3
         outPixels = psPixelsConcatenate(outPixels, testPixels);
-        ok ( outPixels->n == 6,
-             "psPixelsConcatenate:  return properly concatenate pixel list for valid inputs.");
-    }
-
-
-    //Check for Memory leaks
-    {
+        ok(outPixels->n == 6, "psPixelsConcatenate:  return properly concatenate pixel list for valid inputs.");
         psFree(testPixels);
         psFree(outPixels);
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    //Check for Memory leaks
+    //XXX: Remove this, add memory checks to individual blocks
+    {
         psFree(outImage);
         psFree(p1);
