IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9750 for trunk/psLib/test


Ignore:
Timestamp:
Oct 25, 2006, 6:44:09 PM (20 years ago)
Author:
drobbin
Message:

Update MetadataConfig tests. Removed unreachable spots from psMetadataConfigParse.

Location:
trunk/psLib/test/types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/types/tap_psMetadataConfig_input.c

    r9739 r9750  
    1212#include <pslib.h>
    1313#include <string.h>
     14#include <fcntl.h>
     15#include <unistd.h>
     16
    1417
    1518#include "tap.h"
     
    2225int main(void)
    2326{
    24     plan_tests(4);
     27    plan_tests(10);
    2528
    2629    diag("Tests for psMetadataConfig Input Functions");
     
    3942    unsigned int nfail = 0;
    4043    md = psMetadataAlloc();
    41     psMetadataAddS32(md, PS_LIST_HEAD, "new S32", 0, "", 666);
     44    psMetadataAddS32(md, PS_LIST_HEAD, "new_S32", 0, "", 666);
    4245
    4346    //Return NULL for NULL filename input
     
    4750            "psMetadataConfigRead:           return NULL for NULL filename input.");
    4851    }
    49     //Return false for invalid filename input
     52    //Return NULL for invalid filename input
    5053    {
    5154        out = psMetadataConfigRead(out, &nfail, ".", false);
     
    5356            "psMetadataConfigRead:           return NULL for invalid filename input.");
    5457    }
     58    //Return NULL for missing file input
     59    {
     60        out = psMetadataConfigRead(out, &nfail, "table4.dat", false);
     61        ok( out == NULL,
     62            "psMetadataConfigRead:           return NULL for missing file input.");
     63    }
     64    //Return empty metadata for read-only file with invalid syntax
     65    {
     66        out = psMetadataConfigRead(out, &nfail, "table3.dat", false);
     67        ok( out != NULL && out->list->n == 0,
     68            "psMetadataConfigRead:           return empty metadata for file"
     69            " with invalid syntax.");
     70        psFree(out);
     71        out = NULL;
     72    }
    5573    //Return true for valid inputs
    5674    {
    57         skip_start(  !psMetadataConfigWrite(md, "mdcfg.wrt"), 1,
    58                      "Skipping 1 tests because psMetadataConfigWrite failed");
     75        skip_start(  !psMetadataConfigWrite(md, "mdcfg.wrt"), 2,
     76                     "Skipping 2 tests because psMetadataConfigWrite failed");
    5977        out = psMetadataConfigRead(out, &nfail, "mdcfg.wrt", false);
    60         ok( out != NULL,
     78        psMetadataItem *tempItem = psMetadataGet(out, PS_LIST_HEAD);
     79        ok( out != NULL && nfail == 0,
    6180            "psMetadataConfigRead:           return correct metadata for valid inputs.");
     81        skip_start(  tempItem == NULL, 1,
     82                     "Skipping 1 tests because metadata container is empty!");
     83        ok_str( tempItem->name, "new_S32",
     84                "psMetadataConfigRead:           return correct metadataItem from "
     85                "returned metadata.");
     86        skip_end();
    6287        skip_end();
    6388    }
     
    76101{
    77102    diag("  >>>Test 2:  psMetadataConfigParse");
     103    psMetadata *out = NULL;
     104    unsigned int nfail = 0;
     105    char str1[30];
     106    strcpy(str1, "-10.05    2        4");
     107    char str2[30];
     108    strcpy(str2, "\nnew S32       666\n");
     109
     110    //Return NULL for NULL string input
     111    {
     112        out = psMetadataConfigParse(out, &nfail, NULL, false);
     113        ok( out == NULL,
     114            "psMetadataConfigParse:          return NULL for NULL string input.");
     115    }
     116    //Return correct metadata for correct string input
     117    {
     118        psFree(out);
     119        out = NULL;
     120        out = psMetadataConfigParse(out, NULL, str2, false);
     121        psMetadataItem *tempItem = psMetadataGet(out, PS_LIST_HEAD);
     122        ok( out != NULL && tempItem != NULL,
     123            "psMetadataConfigParse:          return correct metadata for valid "
     124            "string input.");
     125    }
     126    //Return empty metadata for incorrect string input
     127    {
     128        psFree(out);
     129        out = NULL;
     130        out = psMetadataConfigParse(out, NULL, str1, false);
     131        psMetadataItem *tempItem = psMetadataGet(out, PS_LIST_HEAD);
     132        ok( out != NULL && tempItem == NULL,
     133            "psMetadataConfigParse:          return correct metadata for valid "
     134            "string input.");
     135        if (tempItem != NULL)
     136            printf("\n\n name=%s\n", tempItem->name);
     137    }
     138
     139
    78140    /*    FILE *openfile;
    79         openfile = fopen("mdcfg.prt", "w+");
    80         FILE *nofile = NULL;
    81         psMetadata *md = NULL;
    82         md = psMetadataAlloc();
    83      
    84         //psMetadataConfigParse(psMetadata* md,unsigned int *nFail,const char *str,bool overwrite)
    85      
    86         //Return false for NULL metadata input
    87         {
    88             ok( !psMetadataConfigPrint(openfile, NULL),
    89                  "psMetadataConfigPrint:           return false for NULL metadata input.");
    90         }
    91         //Return false for empty metadata input
    92         {
    93             ok( !psMetadataConfigPrint(openfile, md),
    94                  "psMetadataConfigPrint:           return false for empty metadata input.");
    95         }
    96         //Return false for NULL file input
    97         psMetadataAddS32(md, PS_LIST_HEAD, "new S32", 0, "", 666);
    98         {
    99             ok( !psMetadataConfigPrint(nofile, md),
    100                  "psMetadataConfigPrint:           return false for NULL FILE* input.");
    101         }
    102         //Return false for read-only file input
    103         nofile = fopen("mdcfg.prt", "r");
    104         {
    105             ok( !psMetadataConfigPrint(nofile, md),
    106                  "psMetadataConfigPrint:           return false for read-only FILE* input.");
    107         }
    108         //Return true for valid inputs
    109         {
    110             ok( psMetadataConfigPrint(openfile, md),
    111                 "psMetadataConfigPrint:           return true for valid inputs.");
    112         }
    113      
    114      
    115         //Check for Memory leaks
    116         {
    117             fclose(nofile);
    118             fclose(openfile);
    119             psFree(md);
    120             remove("mdcfg.prt");
    121             checkMem();
    122         }
    123         */
     141    openfile = fopen("mdcfg.prt", "w+");
     142    FILE *nofile = NULL;
     143    psMetadata *md = NULL;
     144    md = psMetadataAlloc();
     145
     146    //psMetadataConfigParse(psMetadata* md,unsigned int *nFail,const char *str,bool overwrite)
     147
     148    //Return false for NULL metadata input
     149    {
     150        ok( !psMetadataConfigPrint(openfile, NULL),
     151             "psMetadataConfigPrint:           return false for NULL metadata input.");
     152    }
     153    //Return false for empty metadata input
     154    {
     155        ok( !psMetadataConfigPrint(openfile, md),
     156             "psMetadataConfigPrint:           return false for empty metadata input.");
     157    }
     158    //Return false for NULL file input
     159    psMetadataAddS32(md, PS_LIST_HEAD, "new S32", 0, "", 666);
     160    {
     161        ok( !psMetadataConfigPrint(nofile, md),
     162             "psMetadataConfigPrint:           return false for NULL FILE* input.");
     163    }
     164    //Return false for read-only file input
     165    nofile = fopen("mdcfg.prt", "r");
     166    {
     167        ok( !psMetadataConfigPrint(nofile, md),
     168             "psMetadataConfigPrint:           return false for read-only FILE* input.");
     169    }
     170    //Return true for valid inputs
     171    {
     172        ok( psMetadataConfigPrint(openfile, md),
     173            "psMetadataConfigPrint:           return true for valid inputs.");
     174    }
     175
     176    */
     177    //Check for Memory leaks
     178    {
     179        psFree(out);
     180        checkMem();
     181    }
     182
    124183}
    125184
  • trunk/psLib/test/types/tap_psMetadataConfig_output.c

    r9739 r9750  
    124124}
    125125
    126 
    127 /*
    128 void testLookupTableAlloc(void)
    129 {
    130     diag("  >>>Test 1:  psLookupTableAlloc & psMemCheckLookupTable Fxns");
    131  
    132     psLookupTable *lt = NULL;
    133  
    134 //Tests for psLookupTableAlloc
    135    //Return NULL for NULL filename input
    136     {
    137         lt = psLookupTableAlloc(NULL, "\%f \%lf \%d \%ld", 10);
    138         ok( lt == NULL,
    139             "psLookupTableAlloc:               return NULL for NULL filename input.");
    140     }
    141     //Return correct vector output for valid inputs
    142     {
    143         vec = psLookupTableInterpolateAll(table2, 1);
    144         skip_start(  vec == NULL, 1,
    145                      "Skipping 1 tests because psLookupTableInterpolateAll failed");
    146         ok_double(vec->data.F64[0], 1.0,
    147                   "psLookupTableInterpolateAll:     return correct output vector for valid inputs.");
    148         skip_end();
    149     }
    150     //Check for Memory leaks
    151     {
    152         psFree(lt);
    153         checkMem();
    154     }
    155 }
    156 */
    157 
Note: See TracChangeset for help on using the changeset viewer.