Changeset 27303 for trunk/psLib/test/types
- Timestamp:
- Mar 16, 2010, 3:04:24 PM (16 years ago)
- Location:
- trunk/psLib/test/types
- Files:
-
- 1 edited
- 1 moved
-
Makefile.am (modified) (1 diff)
-
tap_psBits_all.c (moved) (moved from trunk/psLib/test/types/tap_psBitSet_all.c ) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/types/Makefile.am
r18145 r27303 29 29 tap_psPixels_all \ 30 30 tap_psHash_all \ 31 tap_psBit Set_all \31 tap_psBits_all \ 32 32 tap_psList_all \ 33 33 tap_psLookupTable_all \ -
trunk/psLib/test/types/tap_psBits_all.c
r27302 r27303 1 1 /** 2 * C Implementation: tap_psBit Set_all3 * 4 * Description: Tests for psBit SetAlloc, psBitSetSet, psMemCheckBitSet, psBitSetClear,5 * psBit SetTest, psBitSetOp, psBitSetNot, psBitSetToString2 * C Implementation: tap_psBits_all 3 * 4 * Description: Tests for psBitsAlloc, psBitsSet, psMemCheckBits, psBitsClear, 5 * psBitsTest, psBitsOp, psBitsNot, psBitsToString 6 6 * 7 7 * Author: dRob <David.Robbins@mhpcc.hpc.mil>, (C) 2006 … … 20 20 psLogSetFormat("HLNM"); 21 21 psLogSetLevel(PS_LOG_INFO); 22 plan_tests(3 1);23 24 25 // testBit SetBasics()22 plan_tests(30); 23 24 25 // testBitsBasics() 26 26 { 27 27 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 44 38 { 45 39 psFree(bs); 46 bs = psBit SetAlloc(8);47 ok( bs != NULL && psMemCheckBit Set(bs) && bs->n == 1,48 "psBit SetAlloc: return properly allocated psBitSet.");49 } 50 //Make sure psMemCheckBit Setworks correctly - return false40 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 51 45 if (0) { 52 46 int j = 2; 53 ok( !psMemCheckBit Set(&j),54 "psMemCheckBit Set: return false for non-BitSetinput.");55 } 56 57 //Bit SetSet Tests58 //Return FALSE for NULL input psBit Set59 { 60 bool rc = psBit SetSet(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); 61 55 ok(rc == false, 62 "psBit SetSet: return FALSE for NULL BitSetinput.");56 "psBitsSet: return FALSE for NULL Bits input."); 63 57 } 64 58 //Return FALSE for negative bit input 65 59 { 66 bool rc = psBit SetSet(bs, -1);67 ok( rc == false, 68 "psBit SetSet: return TRUE for negative bits input.");60 bool rc = psBitsSet(bs, -1); 61 ok( rc == false, 62 "psBitsSet: return TRUE for negative bits input."); 69 63 noBits = NULL; 70 64 } … … 72 66 { 73 67 psFree(bs); 74 bs = psBit SetAlloc(8);75 bool rc = psBit SetSet(bs, 8);76 ok( rc == false, 77 "psBit SetSet: return TRUE for out-of-range bits input.");78 noBits = NULL; 79 } 80 81 //Return set Bit Setfor valid inputs82 { 83 psBit SetSet(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); 84 78 ok( bs->bits[0] == 4, 85 "psBit SetSet: return properly set BitSetfor valid inputs.");86 } 87 88 //Bit SetClear Tests89 //Return FALSE for NULL input psBit Set90 { 91 bool rc = psBit SetClear(noBits, 0);92 ok( rc == false, 93 "psBit SetClear: return FALSE for NULL BitSetinput.");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."); 94 88 } 95 89 //Return FALSE for negative bit input 96 90 { 97 bool rc = psBit SetClear(bs, -1);98 ok( rc == false, 99 "psBit SetClear: return TRUE for negative bits input.");91 bool rc = psBitsClear(bs, -1); 92 ok( rc == false, 93 "psBitsClear: return TRUE for negative bits input."); 100 94 noBits = NULL; 101 95 } 102 96 //Return FALSE for out-of-range bits 103 97 { 104 bool rc = psBit SetClear(bs, 8);105 ok( rc == false, 106 "psBit SetClear: return FALSE for out-of-range bits input.");107 noBits = NULL; 108 } 109 110 //Return cleared Bit Setfor valid inputs111 { 112 psBit SetClear(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); 113 107 ok( bs->bits[0] == 0, 114 "psBit SetClear: return properly cleared BitSetfor valid inputs.");115 } 116 117 //Bit SetTest Tests118 //Return false for NULL input psBit Set119 { 120 ok( !psBit SetTest(noBits, 0),121 "psBit SetTest: return false for NULL BitSetinput.");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."); 122 116 } 123 117 //Return false for negative bit input 124 118 { 125 ok( !psBit SetTest(bs, -1),126 "psBit SetTest: return false for negative bits input.");119 ok( !psBitsTest(bs, -1), 120 "psBitsTest: return false for negative bits input."); 127 121 } 128 122 //Return false for out-of-range bits 129 123 { 130 ok( !psBit SetTest(bs, 8),131 "psBit SetTest: return false for out-of-range bits input.");132 } 133 //Return false for non-matching bit in Bit Set134 { 135 ok( !psBit SetTest(bs, 2),136 "psBit SetTest: return false for non-matching bit in BitSet.");137 } 138 //Return false for non-matching bit in Bit Set139 { 140 psBit SetSet(bs, 2);141 ok( psBit SetTest(bs, 2),142 "psBit SetTest: 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."); 143 137 } 144 138 … … 148 142 149 143 150 // testBit SetOps()144 // testBitsOps() 151 145 { 152 146 psMemId id = psMemGetId(); 153 psBit Set*noBits = NULL;154 psBit Set*bs = NULL;155 bs = psBit SetAlloc(8);156 psBit SetSet(bs, 2); // 0000 0100 == 4157 psBit SetSet(bs, 3); // 0000 1100 == 12158 psBit SetSet(bs, 4); // 0001 1100 == 28159 psBit SetSet(bs, 5); // 0011 1100 == 60160 psBit SetSet(bs, 6); // 0111 1100 == 124161 psBit SetSet(bs, 7); // 1111 1100 == 252162 psBit Set*out = NULL;163 164 //psBit SetNot Tests165 //Return NULL for NULL Bit Setinput166 { 167 out = psBit SetNot(out, noBits);168 ok( out == NULL, 169 "psBit SetNot: return NULL for NULL BitSetinput.");170 } 171 //Return correct Bit Set for valid BitSetinput172 { 173 out = psBit SetNot(out, bs); //bs = 1111 1100 so out should = 0000 0011 = 3147 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 174 168 ok( out->bits[0] == 3, 175 "psBit SetNot: return correct BitSet for valid BitSetinput.");176 } 177 178 //psBit SetOp Tests out = psBitSetOp(out, bs1, "op", bs2);179 //Return NULL for NULL Bit Setinput169 "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 180 174 { 181 175 psFree(out); 182 176 out = NULL; 183 out = psBit SetOp(out, noBits, "op", noBits);184 ok( out == NULL, 185 "psBit SetOp: return NULL for NULL BitSetinput.");177 out = psBitsOp(out, noBits, "op", noBits); 178 ok( out == NULL, 179 "psBitsOp: return NULL for NULL Bits input."); 186 180 } 187 181 //Return NULL for NULL operator input 188 182 { 189 out = psBit SetOp(out, bs, NULL, noBits);190 ok( out == NULL, 191 "psBit SetOp: 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."); 192 186 } 193 187 //Return NULL for invalid operator input 194 188 { 195 out = psBit SetOp(out, bs, "XAND", noBits);196 ok( out == NULL, 197 "psBit SetOp: return NULL for invalid operator input.");198 } 199 //Return NULL for AND operator with NULL second Bit Setinput200 { 201 out = psBit SetOp(out, bs, "AND", noBits);202 ok( out == NULL, 203 "psBit SetOp: return NULL for AND operator with NULL second BitSetinput.");204 } 205 //Return NULL for AND operator with Bit Setinputs of differing size.206 psBit Set *bs2 = psBitSetAlloc(16);207 { 208 out = psBit SetOp(out, bs, "AND", bs2);209 ok( out == NULL, 210 "psBit SetOp: return NULL for AND operator with BitSetinputs 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" 211 205 " differing size."); 212 206 } 213 207 psFree(bs); 214 bs = psBit SetAlloc(16);215 psBit SetSet(bs, 1); // 0000 0010 == 2216 psBit SetSet(bs2, 2); // 0000 0100 == 4217 //Return correct psBit Setoutput for valid inputs with AND operator218 { 219 out = psBit SetOp(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); 220 214 ok( out->bits[0] == 0, 221 "psBit SetOp: return correct psBitSetoutput for valid inputs"215 "psBitsOp: return correct psBits output for valid inputs" 222 216 " with AND operator."); 223 217 } 224 //Return correct psBit Setoutput for valid inputs with OR operator225 { 226 out = psBit SetOp(out, bs, "OR", bs2);218 //Return correct psBits output for valid inputs with OR operator 219 { 220 out = psBitsOp(out, bs, "OR", bs2); 227 221 ok( out->bits[0] == 6, 228 "psBit SetOp: return correct psBitSetoutput for valid inputs"222 "psBitsOp: return correct psBits output for valid inputs" 229 223 " with OR operator."); 230 224 } 231 //Return correct psBit Setoutput for valid inputs with XOR operator232 psBit SetSet(bs2, 1); // 0000 0110 == 6233 { 234 out = psBit SetOp(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); 235 229 ok( out->bits[0] == 4, 236 "psBit SetOp: return correct psBitSetoutput for valid inputs"230 "psBitsOp: return correct psBits output for valid inputs" 237 231 " with XOR operator."); 238 232 } 239 //Return correct psBit Setoutput for valid inputs with NOT operator233 //Return correct psBits output for valid inputs with NOT operator 240 234 { 241 235 psFree(out); 242 out = psBit SetAlloc(0);243 psBit SetSet(bs, 2); // 0000 0110 == 4244 psBit SetSet(bs, 3); // 0000 1110 == 12245 psBit SetSet(bs, 4); // 0001 1110 == 28246 psBit SetSet(bs, 5); // 0011 1110 == 60247 psBit SetSet(bs, 6); // 0111 1110 == 124248 psBit SetSet(bs, 7); // 1111 1110 == 252249 out = psBit SetOp(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); 250 244 ok( out->bits[0] == 1, 251 "psBit SetOp: return correct psBitSetoutput for valid inputs"245 "psBitsOp: return correct psBits output for valid inputs" 252 246 " with NOT operator."); 253 247 } 254 248 255 //psBit SetToString Tests256 //Return NULL for NULL Bit Setinput249 //psBitsToString Tests 250 //Return NULL for NULL Bits input 257 251 psString bitStr = NULL; 258 252 { 259 bitStr = psBit SetToString(noBits);253 bitStr = psBitsToString(noBits); 260 254 ok( bitStr == NULL, 261 "psBit SetToString: return NULL for NULL BitSetinput.");262 } 263 //Return correct string for valid Bit Setinput255 "psBitsToString: return NULL for NULL Bits input."); 256 } 257 //Return correct string for valid Bits input 264 258 { 265 259 psFree(bs); 266 bs = psBit SetAlloc(8);267 psBit SetSet(bs, 2); // 0000 0100 == 4268 bitStr = psBit SetToString(bs);260 bs = psBitsAlloc(8); 261 psBitsSet(bs, 2); // 0000 0100 == 4 262 bitStr = psBitsToString(bs); 269 263 ok( !strncmp(bitStr, "00000100", 10), 270 "psBit SetToString: return correct string for valid BitSet input.");264 "psBitsToString: return correct string for valid Bits input (%s).", bitStr); 271 265 } 272 266
Note:
See TracChangeset
for help on using the changeset viewer.
