IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 16, 2010, 3:04:24 PM (16 years ago)
Author:
Paul Price
Message:

Renaming psBitSet as psBits, and reworking code.

Location:
trunk/psLib/test/types
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/types/Makefile.am

    r18145 r27303  
    2929        tap_psPixels_all \
    3030        tap_psHash_all \
    31         tap_psBitSet_all \
     31        tap_psBits_all \
    3232        tap_psList_all \
    3333        tap_psLookupTable_all \
  • trunk/psLib/test/types/tap_psBits_all.c

    r27302 r27303  
    11/**
    2  *  C Implementation: tap_psBitSet_all
    3  *
    4  * Description:  Tests for psBitSetAlloc, psBitSetSet, psMemCheckBitSet, psBitSetClear,
    5  *               psBitSetTest, psBitSetOp, psBitSetNot, psBitSetToString
     2 *  C Implementation: tap_psBits_all
     3 *
     4 * Description:  Tests for psBitsAlloc, psBitsSet, psMemCheckBits, psBitsClear,
     5 *               psBitsTest, psBitsOp, psBitsNot, psBitsToString
    66 *
    77 * Author: dRob <David.Robbins@mhpcc.hpc.mil>, (C) 2006
     
    2020    psLogSetFormat("HLNM");
    2121    psLogSetLevel(PS_LOG_INFO);
    22     plan_tests(31);
    23 
    24 
    25     // testBitSetBasics()
     22    plan_tests(30);
     23
     24
     25    // testBitsBasics()
    2626    {
    2727        psMemId id = psMemGetId();
    28         psBitSet *noBits = NULL;
    29         psBitSet *bs = NULL;
    30 
    31         //Return NULL for attempt to Allocate BitSet of negative size.
    32         {
    33             noBits = psBitSetAlloc(-1);
    34             ok( noBits == NULL,
    35                 "psBitSetAlloc:         return NULL for negative BitSet-size input.");
    36         }
    37         //Return properly allocated 0-size psBitSet
    38         {
    39             bs = psBitSetAlloc(0);
    40             ok( bs != NULL && psMemCheckBitSet(bs) && bs->n == 0,
    41                 "psBitSetAlloc:         return properly allocated psBitSet.");
    42         }
    43         //Return properly allocated psBitSet
     28        psBits *noBits = NULL;
     29        psBits *bs = NULL;
     30
     31        //Return properly allocated 0-size psBits
     32        {
     33            bs = psBitsAlloc(0);
     34            ok( bs != NULL && psMemCheckBits(bs) && bs->n == 0,
     35                "psBitsAlloc:         return properly allocated psBits.");
     36        }
     37        //Return properly allocated psBits
    4438        {
    4539            psFree(bs);
    46             bs = psBitSetAlloc(8);
    47             ok( bs != NULL && psMemCheckBitSet(bs) && bs->n == 1,
    48                 "psBitSetAlloc:         return properly allocated psBitSet.");
    49         }
    50         //Make sure psMemCheckBitSet works correctly - return false
     40            bs = psBitsAlloc(8);
     41            ok( bs != NULL && psMemCheckBits(bs) && bs->n == 8,
     42                "psBitsAlloc:         return properly allocated psBits.");
     43        }
     44        //Make sure psMemCheckBits works correctly - return false
    5145        if (0) {
    5246            int j = 2;
    53             ok( !psMemCheckBitSet(&j),
    54                 "psMemCheckBitSet:      return false for non-BitSet input.");
    55         }
    56 
    57         //BitSetSet Tests
    58         //Return FALSE for NULL input psBitSet
    59         {
    60             bool rc = psBitSetSet(NULL, 0);
     47            ok( !psMemCheckBits(&j),
     48                "psMemCheckBits:      return false for non-Bits input.");
     49        }
     50
     51        //BitsSet Tests
     52        //Return FALSE for NULL input psBits
     53        {
     54            bool rc = psBitsSet(NULL, 0);
    6155            ok(rc == false,
    62                 "psBitSetSet:           return FALSE for NULL BitSet input.");
     56                "psBitsSet:           return FALSE for NULL Bits input.");
    6357        }
    6458        //Return FALSE for negative bit input
    6559        {
    66             bool rc = psBitSetSet(bs, -1);
    67             ok( rc == false,
    68                 "psBitSetSet:           return TRUE for negative bits input.");
     60            bool rc = psBitsSet(bs, -1);
     61            ok( rc == false,
     62                "psBitsSet:           return TRUE for negative bits input.");
    6963            noBits = NULL;
    7064        }
     
    7266        {
    7367            psFree(bs);
    74             bs = psBitSetAlloc(8);
    75             bool rc = psBitSetSet(bs, 8);
    76             ok( rc == false,
    77                 "psBitSetSet:           return TRUE for out-of-range bits input.");
    78             noBits = NULL;
    79         }
    80 
    81         //Return set BitSet for valid inputs
    82         {
    83             psBitSetSet(bs, 2);
     68            bs = psBitsAlloc(8);
     69            bool rc = psBitsSet(bs, 8);
     70            ok( rc == false,
     71                "psBitsSet:           return TRUE for out-of-range bits input.");
     72            noBits = NULL;
     73        }
     74
     75        //Return set Bits for valid inputs
     76        {
     77            psBitsSet(bs, 2);
    8478            ok( bs->bits[0] == 4,
    85                 "psBitSetSet:           return properly set BitSet for valid inputs.");
    86         }
    87 
    88         //BitSetClear Tests
    89         //Return FALSE for NULL input psBitSet
    90         {
    91             bool rc = psBitSetClear(noBits, 0);
    92             ok( rc == false,
    93                 "psBitSetClear:         return FALSE for NULL BitSet input.");
     79                "psBitsSet:           return properly set Bits for valid inputs.");
     80        }
     81
     82        //BitsClear Tests
     83        //Return FALSE for NULL input psBits
     84        {
     85            bool rc = psBitsClear(noBits, 0);
     86            ok( rc == false,
     87                "psBitsClear:         return FALSE for NULL Bits input.");
    9488        }
    9589        //Return FALSE for negative bit input
    9690        {
    97             bool rc = psBitSetClear(bs, -1);
    98             ok( rc == false,
    99                 "psBitSetClear:        return TRUE for negative bits input.");
     91            bool rc = psBitsClear(bs, -1);
     92            ok( rc == false,
     93                "psBitsClear:        return TRUE for negative bits input.");
    10094            noBits = NULL;
    10195        }
    10296        //Return FALSE for out-of-range bits
    10397        {
    104             bool rc = psBitSetClear(bs, 8);
    105             ok( rc == false,
    106                 "psBitSetClear:        return FALSE for out-of-range bits input.");
    107             noBits = NULL;
    108         }
    109 
    110         //Return cleared BitSet for valid inputs
    111         {
    112             psBitSetClear(bs, 2);
     98            bool rc = psBitsClear(bs, 8);
     99            ok( rc == false,
     100                "psBitsClear:        return FALSE for out-of-range bits input.");
     101            noBits = NULL;
     102        }
     103
     104        //Return cleared Bits for valid inputs
     105        {
     106            psBitsClear(bs, 2);
    113107            ok( bs->bits[0] == 0,
    114                 "psBitSetClear:        return properly cleared BitSet for valid inputs.");
    115         }
    116 
    117         //BitSetTest Tests
    118         //Return false for NULL input psBitSet
    119         {
    120             ok( !psBitSetTest(noBits, 0),
    121                 "psBitSetTest:         return false for NULL BitSet input.");
     108                "psBitsClear:        return properly cleared Bits for valid inputs.");
     109        }
     110
     111        //BitsTest Tests
     112        //Return false for NULL input psBits
     113        {
     114            ok( !psBitsTest(noBits, 0),
     115                "psBitsTest:         return false for NULL Bits input.");
    122116        }
    123117        //Return false for negative bit input
    124118        {
    125             ok( !psBitSetTest(bs, -1),
    126                 "psBitSetTest:         return false for negative bits input.");
     119            ok( !psBitsTest(bs, -1),
     120                "psBitsTest:         return false for negative bits input.");
    127121        }
    128122        //Return false for out-of-range bits
    129123        {
    130             ok( !psBitSetTest(bs, 8),
    131                 "psBitSetTest:         return false for out-of-range bits input.");
    132         }
    133         //Return false for non-matching bit in BitSet
    134         {
    135             ok( !psBitSetTest(bs, 2),
    136                 "psBitSetTest:         return false for non-matching bit in BitSet.");
    137         }
    138         //Return false for non-matching bit in BitSet
    139         {
    140             psBitSetSet(bs, 2);
    141             ok( psBitSetTest(bs, 2),
    142                 "psBitSetTest:         return true for matching bit in BitSet.");
     124            ok( !psBitsTest(bs, 8),
     125                "psBitsTest:         return false for out-of-range bits input.");
     126        }
     127        //Return false for non-matching bit in Bits
     128        {
     129            ok( !psBitsTest(bs, 2),
     130                "psBitsTest:         return false for non-matching bit in Bits.");
     131        }
     132        //Return false for non-matching bit in Bits
     133        {
     134            psBitsSet(bs, 2);
     135            ok( psBitsTest(bs, 2),
     136                "psBitsTest:         return true for matching bit in Bits.");
    143137        }
    144138
     
    148142
    149143
    150     // testBitSetOps()
     144    // testBitsOps()
    151145    {
    152146        psMemId id = psMemGetId();
    153         psBitSet *noBits = NULL;
    154         psBitSet *bs = NULL;
    155         bs = psBitSetAlloc(8);
    156         psBitSetSet(bs, 2);  // 0000 0100 == 4
    157         psBitSetSet(bs, 3);  // 0000 1100 == 12
    158         psBitSetSet(bs, 4);  // 0001 1100 == 28
    159         psBitSetSet(bs, 5);  // 0011 1100 == 60
    160         psBitSetSet(bs, 6);  // 0111 1100 == 124
    161         psBitSetSet(bs, 7);  // 1111 1100 == 252
    162         psBitSet *out = NULL;
    163 
    164         //psBitSetNot Tests
    165         //Return NULL for NULL BitSet input
    166         {
    167             out = psBitSetNot(out, noBits);
    168             ok( out == NULL,
    169                 "psBitSetNot:          return NULL for NULL BitSet input.");
    170         }
    171         //Return correct BitSet for valid BitSet input
    172         {
    173             out = psBitSetNot(out, bs);  //bs = 1111 1100  so out should = 0000 0011 = 3
     147        psBits *noBits = NULL;
     148        psBits *bs = NULL;
     149        bs = psBitsAlloc(8);
     150        psBitsSet(bs, 2);  // 0000 0100 == 4
     151        psBitsSet(bs, 3);  // 0000 1100 == 12
     152        psBitsSet(bs, 4);  // 0001 1100 == 28
     153        psBitsSet(bs, 5);  // 0011 1100 == 60
     154        psBitsSet(bs, 6);  // 0111 1100 == 124
     155        psBitsSet(bs, 7);  // 1111 1100 == 252
     156        psBits *out = NULL;
     157
     158        //psBitsNot Tests
     159        //Return NULL for NULL Bits input
     160        {
     161            out = psBitsNot(out, noBits);
     162            ok( out == NULL,
     163                "psBitsNot:          return NULL for NULL Bits input.");
     164        }
     165        //Return correct Bits for valid Bits input
     166        {
     167            out = psBitsNot(out, bs);  //bs = 1111 1100  so out should = 0000 0011 = 3
    174168            ok( out->bits[0] == 3,
    175                 "psBitSetNot:          return correct BitSet for valid BitSet input.");
    176         }
    177 
    178         //psBitSetOp Tests   out = psBitSetOp(out, bs1, "op", bs2);
    179         //Return NULL for NULL BitSet input
     169                "psBitsNot:          return correct Bits for valid Bits input.");
     170        }
     171
     172        //psBitsOp Tests   out = psBitsOp(out, bs1, "op", bs2);
     173        //Return NULL for NULL Bits input
    180174        {
    181175            psFree(out);
    182176            out = NULL;
    183             out = psBitSetOp(out, noBits, "op", noBits);
    184             ok( out == NULL,
    185                 "psBitSetOp:           return NULL for NULL BitSet input.");
     177            out = psBitsOp(out, noBits, "op", noBits);
     178            ok( out == NULL,
     179                "psBitsOp:           return NULL for NULL Bits input.");
    186180        }
    187181        //Return NULL for NULL operator input
    188182        {
    189             out = psBitSetOp(out, bs, NULL, noBits);
    190             ok( out == NULL,
    191                 "psBitSetOp:           return NULL for NULL operator input.");
     183            out = psBitsOp(out, bs, NULL, noBits);
     184            ok( out == NULL,
     185                "psBitsOp:           return NULL for NULL operator input.");
    192186        }
    193187        //Return NULL for invalid operator input
    194188        {
    195             out = psBitSetOp(out, bs, "XAND", noBits);
    196             ok( out == NULL,
    197                 "psBitSetOp:           return NULL for invalid operator input.");
    198         }
    199         //Return NULL for AND operator with NULL second BitSet input
    200         {
    201             out = psBitSetOp(out, bs, "AND", noBits);
    202             ok( out == NULL,
    203                 "psBitSetOp:           return NULL for AND operator with NULL second BitSet input.");
    204         }
    205         //Return NULL for AND operator with BitSet inputs of differing size.
    206         psBitSet *bs2 = psBitSetAlloc(16);
    207         {
    208             out = psBitSetOp(out, bs, "AND", bs2);
    209             ok( out == NULL,
    210                 "psBitSetOp:           return NULL for AND operator with BitSet inputs of"
     189            out = psBitsOp(out, bs, "XAND", noBits);
     190            ok( out == NULL,
     191                "psBitsOp:           return NULL for invalid operator input.");
     192        }
     193        //Return NULL for AND operator with NULL second Bits input
     194        {
     195            out = psBitsOp(out, bs, "AND", noBits);
     196            ok( out == NULL,
     197                "psBitsOp:           return NULL for AND operator with NULL second Bits input.");
     198        }
     199        //Return NULL for AND operator with Bits inputs of differing size.
     200        psBits *bs2 = psBitsAlloc(16);
     201        {
     202            out = psBitsOp(out, bs, "AND", bs2);
     203            ok( out == NULL,
     204                "psBitsOp:           return NULL for AND operator with Bits inputs of"
    211205                " differing size.");
    212206        }
    213207        psFree(bs);
    214         bs = psBitSetAlloc(16);
    215         psBitSetSet(bs, 1);     // 0000 0010 == 2
    216         psBitSetSet(bs2, 2);   // 0000 0100 == 4
    217         //Return correct psBitSet output for valid inputs with AND operator
    218         {
    219             out = psBitSetOp(out, bs, "AND", bs2);
     208        bs = psBitsAlloc(16);
     209        psBitsSet(bs, 1);     // 0000 0010 == 2
     210        psBitsSet(bs2, 2);   // 0000 0100 == 4
     211        //Return correct psBits output for valid inputs with AND operator
     212        {
     213            out = psBitsOp(out, bs, "AND", bs2);
    220214            ok( out->bits[0] == 0,
    221                 "psBitSetOp:           return correct psBitSet output for valid inputs"
     215                "psBitsOp:           return correct psBits output for valid inputs"
    222216                " with AND operator.");
    223217        }
    224         //Return correct psBitSet output for valid inputs with OR operator
    225         {
    226             out = psBitSetOp(out, bs, "OR", bs2);
     218        //Return correct psBits output for valid inputs with OR operator
     219        {
     220            out = psBitsOp(out, bs, "OR", bs2);
    227221            ok( out->bits[0] == 6,
    228                 "psBitSetOp:           return correct psBitSet output for valid inputs"
     222                "psBitsOp:           return correct psBits output for valid inputs"
    229223                " with OR operator.");
    230224        }
    231         //Return correct psBitSet output for valid inputs with XOR operator
    232         psBitSetSet(bs2, 1);     // 0000 0110 == 6
    233         {
    234             out = psBitSetOp(out, bs, "XOR", bs2);
     225        //Return correct psBits output for valid inputs with XOR operator
     226        psBitsSet(bs2, 1);     // 0000 0110 == 6
     227        {
     228            out = psBitsOp(out, bs, "XOR", bs2);
    235229            ok( out->bits[0] == 4,
    236                 "psBitSetOp:           return correct psBitSet output for valid inputs"
     230                "psBitsOp:           return correct psBits output for valid inputs"
    237231                " with XOR operator.");
    238232        }
    239         //Return correct psBitSet output for valid inputs with NOT operator
     233        //Return correct psBits output for valid inputs with NOT operator
    240234        {
    241235            psFree(out);
    242             out = psBitSetAlloc(0);
    243             psBitSetSet(bs, 2);  // 0000 0110 == 4
    244             psBitSetSet(bs, 3);  // 0000 1110 == 12
    245             psBitSetSet(bs, 4);  // 0001 1110 == 28
    246             psBitSetSet(bs, 5);  // 0011 1110 == 60
    247             psBitSetSet(bs, 6);  // 0111 1110 == 124
    248             psBitSetSet(bs, 7);  // 1111 1110 == 252
    249             out = psBitSetOp(out, bs, "NOT", bs2);
     236            out = psBitsAlloc(0);
     237            psBitsSet(bs, 2);  // 0000 0110 == 4
     238            psBitsSet(bs, 3);  // 0000 1110 == 12
     239            psBitsSet(bs, 4);  // 0001 1110 == 28
     240            psBitsSet(bs, 5);  // 0011 1110 == 60
     241            psBitsSet(bs, 6);  // 0111 1110 == 124
     242            psBitsSet(bs, 7);  // 1111 1110 == 252
     243            out = psBitsOp(out, bs, "NOT", bs2);
    250244            ok( out->bits[0] == 1,
    251                 "psBitSetOp:           return correct psBitSet output for valid inputs"
     245                "psBitsOp:           return correct psBits output for valid inputs"
    252246                " with NOT operator.");
    253247        }
    254248
    255         //psBitSetToString Tests
    256         //Return NULL for NULL BitSet input
     249        //psBitsToString Tests
     250        //Return NULL for NULL Bits input
    257251        psString bitStr = NULL;
    258252        {
    259             bitStr = psBitSetToString(noBits);
     253            bitStr = psBitsToString(noBits);
    260254            ok( bitStr == NULL,
    261                 "psBitSetToString:     return NULL for NULL BitSet input.");
    262         }
    263         //Return correct string for valid BitSet input
     255                "psBitsToString:     return NULL for NULL Bits input.");
     256        }
     257        //Return correct string for valid Bits input
    264258        {
    265259            psFree(bs);
    266             bs = psBitSetAlloc(8);
    267             psBitSetSet(bs, 2);  // 0000 0100 == 4
    268             bitStr = psBitSetToString(bs);
     260            bs = psBitsAlloc(8);
     261            psBitsSet(bs, 2);  // 0000 0100 == 4
     262            bitStr = psBitsToString(bs);
    269263            ok( !strncmp(bitStr, "00000100", 10),
    270                 "psBitSetToString:     return correct string for valid BitSet input.");
     264                "psBitsToString:     return correct string for valid Bits input (%s).", bitStr);
    271265        }
    272266
Note: See TracChangeset for help on using the changeset viewer.