Changeset 965 for trunk/psLib/test/collections/tst_psBitSet_01.c
- Timestamp:
- Jun 9, 2004, 2:29:09 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/collections/tst_psBitSet_01.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/collections/tst_psBitSet_01.c
r717 r965 5 5 * This test driver contains the following tests for psArray test point 1: 6 6 * A) Create psBitSet 7 * B) Set single bit 8 * C) Test single bit 9 * D) Free psBitSet 7 * B) Set bits 8 * C) Test bits 9 * D) Attempt to test negative bit 10 * E) Attempt to test bit to large 11 * F) Attempt to test bit in null BitSet 12 * G) Attempt to set negative bit 13 * H) Attempt to set bit to large 14 * I) Attempt to set bit in null BitSet 15 * J) Free psBitSet 10 16 * 11 17 * @author Ross Harman, MHPCC 12 18 * 13 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-0 5-18 19:22:34$19 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 20 * @date $Date: 2004-06-10 00:28:23 $ 15 21 * 16 22 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 31 { 26 32 char *binOut = NULL; 33 psBitSet *tempBs = NULL; 27 34 28 35 … … 30 37 printPositiveTestHeader(stdout,"psBitSet", "Create psBitSet"); 31 38 printf("Creating psBitSet with 24 bits...\n"); 32 psBitSet* bs = psBitSetAlloc( 3);39 psBitSet* bs = psBitSetAlloc(24); 33 40 binOut = psBitSetToString(bs); 34 41 printf("%s\n\n", binOut); … … 37 44 38 45 39 // Test B - Set single bit 40 printPositiveTestHeader(stdout, "psBitSet", "Set single bit"); 46 // Test B - Set bits 47 printPositiveTestHeader(stdout, "psBitSet", "Set bits"); 48 tempBs = bs; 49 printf("Setting first bit...\n"); 50 bs = psBitSetSet(bs, 0); 41 51 printf("Setting third bit...\n"); 42 52 bs = psBitSetSet(bs, 2); 53 printf("Setting last bit...\n"); 54 bs = psBitSetSet(bs, 23); 55 if(bs != tempBs) { 56 printf("Error: Return pointer not equal to output argument pointer\n"); 57 } 43 58 binOut = psBitSetToString(bs); 44 59 printf("%s\n\n", binOut); 45 60 psFree(binOut); 46 printFooter(stdout, "psBitSet", "Set single bit", true);61 printFooter(stdout, "psBitSet", "Set bits", true); 47 62 48 63 49 // Test C - Test single bit 50 printPositiveTestHeader(stdout, "psBitSet", "Test single bit"); 64 // Test C - Test bits 65 printPositiveTestHeader(stdout, "psBitSet", "Test bits"); 66 printf("Testing first bit...\n"); 67 printf("Result: %d\n", psBitSetTest(bs, 0)); 51 68 printf("Testing third bit...\n"); 52 69 printf("Result: %d\n", psBitSetTest(bs, 2)); 53 printFooter(stdout, "psBitSet", "Test single bit", true); 70 printf("Testing last bit...\n"); 71 printf("Result: %d\n", psBitSetTest(bs, 23)); 72 printFooter(stdout, "psBitSet", "Test bits", true); 54 73 55 74 56 // Test D - Free psBitSet 75 // Test D - Attempt to test negative bit 76 printNegativeTestHeader(stdout,"psBitSet", "Attempt to test negative bit", 77 "Bit position too small: -4", 0); 78 if(psBitSetTest(bs, -4)) { 79 printf("Error: Return value should be zero\n"); 80 } 81 printFooter(stdout, "psBitSet", "Attempt to test negative bit", true); 82 83 84 // Test E - Attempt to test bit to large 85 printNegativeTestHeader(stdout,"psBitSet", "Attempt to test bit to large", 86 "Bit position too large: 200", 0); 87 if(psBitSetTest(bs, 200)) { 88 printf("Error: Return value should be zero\n"); 89 } 90 printFooter(stdout, "psBitSet", "Attempt to test bit to large", true); 91 92 93 // Test F - Attempt to test bit in null BitSet 94 printNegativeTestHeader(stdout,"psBitSet", "Attempt to test bit in null BitSet", 95 "Null psBitSet for inBitSet argument", 0); 96 psBitSetTest(NULL, 0); 97 printFooter(stdout, "psBitSet", "Attempt to test bit in null BitSet", true); 98 99 100 // Test G - Attempt to set negative bit 101 printNegativeTestHeader(stdout,"psBitSet", "Attempt to set negative bit", 102 "Bit position too small: -4", 0); 103 bs = psBitSetSet(bs, -4); 104 printFooter(stdout, "psBitSet", "Attempt to set negative bit", true); 105 106 107 // Test H - Attempt to set bit to large 108 printNegativeTestHeader(stdout,"psBitSet", "Attempt to set bit to large", 109 "Bit position too large: 200", 0); 110 bs = psBitSetSet(bs, 200); 111 printFooter(stdout, "psBitSet", "Attempt to set bit to large", true); 112 113 114 // Test I - Attempt to set bit in null BitSet 115 printNegativeTestHeader(stdout,"psBitSet", "Attempt to set bit in null BitSet", 116 "Null psBitSet for inBitSet argument", 0); 117 psBitSetSet(NULL, 0); 118 printFooter(stdout, "psBitSet", "Attempt to set bit in null BitSet", true); 119 120 121 // Test J - Free psBitSet 57 122 printPositiveTestHeader(stdout, "psBitSet", "Free psBitSet"); 58 123 psBitSetFree(bs);
Note:
See TracChangeset
for help on using the changeset viewer.
