IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2879


Ignore:
Timestamp:
Jan 3, 2005, 4:34:58 PM (22 years ago)
Author:
desonia
Message:

added tests for psRegion functions.

Location:
trunk/psLib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/Makefile.Globals

    r2869 r2879  
    66##  Assumptions:    Variable "prefix" already defined
    77##
    8 ##  $Revision: 1.37 $  $Name: not supported by cvs2svn $
    9 ##  $Date: 2005-01-03 23:37:52 $
     8##  $Revision: 1.38 $  $Name: not supported by cvs2svn $
     9##  $Date: 2005-01-04 02:34:56 $
    1010##
    1111##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6161
    6262XML2_CFLAGS := $(shell $(xml2config) --cflags)
    63 XML2_CFLAGS = -I/usr/local/include/libxml2
    6463
    6564# Set initial value for CFLAGS which will include all OS common flags for GCC
  • trunk/psLib/src/image/psImage.c

    r2762 r2879  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-12-20 21:39:42 $
     11 *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-01-04 02:34:57 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "psError.h"
    2424#include "psImage.h"
     25#include "psString.h"
    2526
    2627#include "psImageErrors.h"
     
    146147
    147148    return psRegionAlloc(col0,col1,row0,row1);
     149}
     150
     151char* psRegionToString(psRegion* region)
     152{
     153    char tmpText[256]; // big enough to store any region as text
     154
     155    if (region == NULL) {
     156        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     157                PS_ERRORTEXT_psImage_REGION_NULL);
     158        return NULL;
     159    }
     160
     161    snprintf(tmpText,256,"[%g:%g,%g:%g]",
     162             region->x0, region->x1,
     163             region->y0, region->y1);
     164
     165    return psStringCopy(tmpText);
    148166}
    149167
  • trunk/psLib/src/image/psImage.h

    r2375 r2879  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-11-16 20:00:21 $
     13 *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-01-04 02:34:57 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    103103);
    104104
    105 /** Create an image of the specified size and type.
    106  *
    107  * Uses psLib memory allocation functions to create an image struct of the
    108  * specified size and type.
    109  *
    110  * @return psImage* : Pointer to psImage.
     105/** Create a psRegion with the specified attributes.
     106 *
     107 * Uses psLib memory allocation functions to create a psRegion the
     108 * specified x0, x1, y0, and y1.
     109 *
     110 * @return psRegion* : Pointer to psRegion.
    111111 *
    112112 */
     
    118118);
    119119
     120/** Create a psRegion with the attribute values given as a string.
     121 *
     122 *  Create a psRegion with the attribute values given as a string.  The format
     123 *  shall be of the standard IRAF form '[x0:x1,y0:y1]'
     124 *
     125 *  @return psRegion*:  A new psRegion struct, or NULL is not successful.
     126 */
    120127psRegion* psRegionFromString(
    121128    char* region                       ///< image rectangular region in the form '[x0:x1,y0:y1]'
     129);
     130
     131/** Create a string of the standard IRAF form '[x0:x1,y0:y1]' from a psRegion.
     132 *
     133 *  @return char*:  A new string representing the psRegion as text, or NULL
     134 *                  is not successful.
     135 */
     136char* psRegionToString(
     137    psRegion* region                   ///< the psRegion to convert to a string
    122138);
    123139
  • trunk/psLib/src/image/psImageErrors.dat

    r2093 r2879  
    1313psImage_IMAGE_TYPE_UNSUPPORTED         Specified psImage type, %s, is not supported.
    1414psImage_INTERPOLATE_METHOD_INVALID     Specified interpolation method (%d) is not supported.
     15psImage_REGION_NULL                    Specified psRegion is NULL.  Operation could not be performed.
    1516psImage_SUBSET_RANGE_INVALID           Specified subset range, [%d:%d,%d:%d], is invalid or outside input psImage's boundaries, [0:%d,0:%d].
    1617psImage_SUBSET_RANGE_MALFORMED         Specified subset range, [%d:%d,%d:%d], is invalid.  Ranges must be incremental.
     
    6768psImageManip_OPERATION_NULL            Operation can not be NULL.
    6869psImageManip_OVERLAY_TYPE_MISMATCH     Input overlay psImage type, %s, must match input psImage type, %s.
    69 psImageManip_CLIP_VALUE_INVALID        Specified %s value, %g%+gi, is not the the range of input psImage's valid pixel values (%s), i.e. [%g:%g]. 
     70psImageManip_CLIP_VALUE_INVALID        Specified %s value, %g%+gi, is not the the range of input psImage's valid pixel values (%s), i.e. [%g:%g].
    7071psImageManip_OVERLAY_OPERATOR_INVALID  Specified operation, '%s', is not supported.
    7172psImageManip_SCALE_NOT_POSITIVE        Specified scale value, %d, must be a positive value.
     
    7677psImageConvolve_FFT_FAILED             Failed to perform a fourier transform of input image.
    7778psImageConvolve_KERNEL_FFT_FAILED      Failed to perform a fourier transform of kernel.
    78 psImageConvolve_KERNEL_TOO_LARGE       Specified psKernel size, %dx%d, can not be larger than input psImage size, %dx%d. 
    79 psImage_COEFF_NULL                     Polynomial coefficients cannot be NULL. 
     79psImageConvolve_KERNEL_TOO_LARGE       Specified psKernel size, %dx%d, can not be larger than input psImage size, %dx%d.
     80psImage_COEFF_NULL                     Polynomial coefficients cannot be NULL.
  • trunk/psLib/src/image/psImageErrors.h

    r2375 r2879  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-11-16 20:00:21 $
     9 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-01-04 02:34:57 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#define PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED "Specified psImage type, %s, is not supported."
    3636#define PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID "Specified interpolation method (%d) is not supported."
     37#define PS_ERRORTEXT_psImage_REGION_NULL "Specified psRegion is NULL.  Operation could not be performed."
    3738#define PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID "Specified subset range, [%d:%d,%d:%d], is invalid or outside input psImage's boundaries, [0:%d,0:%d]."
    3839#define PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED "Specified subset range, [%d:%d,%d:%d], is invalid.  Ranges must be incremental."
     
    8687#define PS_ERRORTEXT_psImageManip_OPERATION_NULL "Operation can not be NULL."
    8788#define PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH "Input overlay psImage type, %s, must match input psImage type, %s."
    88 #define PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID "Specified %s value, %g%+gi, is not the the range of input psImage's valid pixel values (%s), i.e. [%g:%g].  "
     89#define PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID "Specified %s value, %g%+gi, is not the the range of input psImage's valid pixel values (%s), i.e. [%g:%g]."
    8990#define PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID "Specified operation, '%s', is not supported."
    9091#define PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE "Specified scale value, %d, must be a positive value."
     
    9596#define PS_ERRORTEXT_psImageConvolve_FFT_FAILED "Failed to perform a fourier transform of input image."
    9697#define PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED "Failed to perform a fourier transform of kernel."
    97 #define PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE "Specified psKernel size, %dx%d, can not be larger than input psImage size, %dx%d. "
    98 #define PS_ERRORTEXT_psImage_COEFF_NULL "Polynomial coefficients cannot be NULL. "
     98#define PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE "Specified psKernel size, %dx%d, can not be larger than input psImage size, %dx%d."
     99#define PS_ERRORTEXT_psImage_COEFF_NULL "Polynomial coefficients cannot be NULL."
    99100//~End
    100101
  • trunk/psLib/src/mathtypes/psImage.c

    r2762 r2879  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-12-20 21:39:42 $
     11 *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-01-04 02:34:57 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "psError.h"
    2424#include "psImage.h"
     25#include "psString.h"
    2526
    2627#include "psImageErrors.h"
     
    146147
    147148    return psRegionAlloc(col0,col1,row0,row1);
     149}
     150
     151char* psRegionToString(psRegion* region)
     152{
     153    char tmpText[256]; // big enough to store any region as text
     154
     155    if (region == NULL) {
     156        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     157                PS_ERRORTEXT_psImage_REGION_NULL);
     158        return NULL;
     159    }
     160
     161    snprintf(tmpText,256,"[%g:%g,%g:%g]",
     162             region->x0, region->x1,
     163             region->y0, region->y1);
     164
     165    return psStringCopy(tmpText);
    148166}
    149167
  • trunk/psLib/src/mathtypes/psImage.h

    r2375 r2879  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-11-16 20:00:21 $
     13 *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-01-04 02:34:57 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    103103);
    104104
    105 /** Create an image of the specified size and type.
    106  *
    107  * Uses psLib memory allocation functions to create an image struct of the
    108  * specified size and type.
    109  *
    110  * @return psImage* : Pointer to psImage.
     105/** Create a psRegion with the specified attributes.
     106 *
     107 * Uses psLib memory allocation functions to create a psRegion the
     108 * specified x0, x1, y0, and y1.
     109 *
     110 * @return psRegion* : Pointer to psRegion.
    111111 *
    112112 */
     
    118118);
    119119
     120/** Create a psRegion with the attribute values given as a string.
     121 *
     122 *  Create a psRegion with the attribute values given as a string.  The format
     123 *  shall be of the standard IRAF form '[x0:x1,y0:y1]'
     124 *
     125 *  @return psRegion*:  A new psRegion struct, or NULL is not successful.
     126 */
    120127psRegion* psRegionFromString(
    121128    char* region                       ///< image rectangular region in the form '[x0:x1,y0:y1]'
     129);
     130
     131/** Create a string of the standard IRAF form '[x0:x1,y0:y1]' from a psRegion.
     132 *
     133 *  @return char*:  A new string representing the psRegion as text, or NULL
     134 *                  is not successful.
     135 */
     136char* psRegionToString(
     137    psRegion* region                   ///< the psRegion to convert to a string
    122138);
    123139
  • trunk/psLib/test/image/tst_psImage.c

    r2273 r2879  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-04 01:05:00 $
     8 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-01-04 02:34:58 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2323static psS32 testImageAlloc(void);
    2424static psS32 testImageCopy(void);
     25static psS32 testRegion(void);
    2526
    2627testDescription tests[] = {
     
    2829                              {testImageAlloc,548,"psImageFree",0,true},
    2930                              {testImageCopy,551,"psImageCopy",0,false},
     31                              {testRegion,790,"psRegionAlloc",0,false},
     32                              {testRegion,791,"psRegionFromString",0,true},
    3033                              {NULL}
    3134                          };
     
    394397}
    395398
     399static psS32 testRegion(void)
     400{
     401    int testNum = 0;
     402
     403
     404    // Testpoint #790
     405
     406    psRegion* region = psRegionAlloc(1,2,3,4);
     407
     408    testNum++;
     409    if (region == NULL) {
     410        psError(PS_ERR_UNKNOWN, false,
     411                "psRegionAlloc returned a NULL pointer.");
     412        return testNum;
     413    }
     414
     415    testNum++;
     416    if (region->x0 != 1 || region->x1 != 2 || region->y0 != 3 || region->y1 != 4) {
     417        psError(PS_ERR_UNKNOWN, false,
     418                "The region attributes are not set properly (%s)",
     419                psRegionToString(region));
     420        return testNum;
     421    }
     422
     423    psFree(region);
     424
     425    // Testpoint #791
     426
     427    region = psRegionFromString("[1:2,3:4]");
     428
     429    testNum++;
     430    if (region == NULL) {
     431        psError(PS_ERR_UNKNOWN, false,
     432                "psRegionFromString returned a NULL pointer.");
     433        return testNum;
     434    }
     435
     436    testNum++;
     437    if (region->x0 != 1 || region->x1 != 2 || region->y0 != 3 || region->y1 != 4) {
     438        psError(PS_ERR_UNKNOWN, false,
     439                "The region attributes are not set properly (%s)",
     440                psRegionToString(region));
     441        return testNum;
     442    }
     443
     444    psFree(region);
     445    region = psRegionFromString("[1:2,3:]");
     446
     447    testNum++;
     448    if (region != NULL) {
     449        psError(PS_ERR_UNKNOWN, false,
     450                "psRegionFromString returned a non-NULL pointer given a malformed string.");
     451        return testNum;
     452    }
     453
     454    return 0;
     455}
  • trunk/psLib/test/image/verified/tst_psImage.stderr

    r2279 r2879  
    117117---> TESTPOINT PASSED (psImage{psImageCopy} | tst_psImage.c)
    118118
     119/***************************** TESTPOINT ******************************************\
     120*             TestFile: tst_psImage.c                                              *
     121*            TestPoint: psImage{psRegionAlloc}                                     *
     122*             TestType: Positive                                                   *
     123\**********************************************************************************/
     124
     125<DATE><TIME>|<HOST>|E|psRegionFromString (psImage.c:<LINENO>)
     126    Specified subsection string, '[1:<LINENO>,3:]', can not be parsed.  Must be in the form '[x1:x2,y1:y2]'.
     127
     128---> TESTPOINT PASSED (psImage{psRegionAlloc} | tst_psImage.c)
     129
Note: See TracChangeset for help on using the changeset viewer.