Changeset 12781 for trunk/psLib/test/sys/tap_psLine.c
- Timestamp:
- Apr 10, 2007, 11:09:31 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sys/tap_psLine.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sys/tap_psLine.c
r12550 r12781 5 5 * @author dRob, MHPCC 6 6 * 7 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 3-22 22:47:07$7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-04-10 21:09:31 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 17 17 #include "string.h" 18 18 19 static psS32 testLineAlloc(void); 20 static psS32 testLineInit(void); 21 static psS32 testLineAdd(void); 22 static psS32 testLineChk(void); 19 psS32 main( psS32 argc, char* argv[] ) 20 { 21 plan_tests(16); 22 psLogSetFormat("HLNM"); 23 psLogSetLevel(PS_LOG_INFO); 24 25 //testLineAlloc() 26 { 27 psMemId id = psMemGetId(); 28 psLine *lineline = NULL; 29 lineline = psLineAlloc(20); 30 ok(lineline->NLINE==20, "psLine set NLINE parameter during Allocation"); 31 ok(lineline->Nline == 0, "psLine set Nline parameter during Allocation"); 32 strncpy(lineline->line, "Hello World", 20); 33 ok(!strncmp(lineline->line, "Hello World", 20), 34 "psLine was stored a simple string!"); 35 psFree(lineline); 36 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 37 } 38 39 // testLineInit() 40 { 41 psMemId id = psMemGetId(); 42 psLine *line = NULL; 43 //Return false for NULL input 44 int okay = !psLineInit(line); 45 ok(okay, "psLineInit. Expected false for NULL psLine input"); 46 //Allocate a line and return true on Init 47 line = psLineAlloc(1); 48 okay = psLineInit(line); 49 ok(okay, "psLineInit. Expected true for valid psLine input"); 50 ok(line->NLINE == 1 && line->Nline == 0, "psLineInit returned line parameters."); 51 psFree(line); 52 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 53 } 23 54 24 55 25 psS32 main( psS32 argc, char* argv[] ) 26 { 27 plan_tests(12); 28 29 testLineAlloc(); 30 testLineInit(); 31 testLineAdd(); 32 testLineChk(); 33 } 34 35 psS32 testLineAlloc(void) 36 { 37 // diag("testLineAlloc"); 38 39 psLine *lineline = NULL; 40 lineline = psLineAlloc(20); 41 42 ok (lineline->NLINE==20, "psLine set NLINE parameter during Allocation"); 43 skip_start (lineline->NLINE != 20, 44 2, "psLine set NLINE parameter during Allocation"); 45 46 ok (lineline->Nline == 0, 47 "psLine set Nline parameter during Allocation\n"); 48 skip_start (lineline->Nline == 0, 49 1, "psLine set Nline parameter during Allocation\n"); 50 51 strncpy(lineline->line, "Hello World", 20); 52 ok (!strncmp(lineline->line, "Hello World", 20), 53 "psLine was stored a simple string!\n"); 54 55 skip_end(); 56 skip_end(); 57 58 psFree(lineline); 59 60 return 0; 61 } 62 63 psS32 testLineInit(void) 64 { 65 // diag("testLineInit"); 66 67 psLine *line = NULL; 68 //Return false for NULL input 69 int okay = !psLineInit(line); 70 ok (okay, "psLineInit. Expected false for NULL psLine input.\n"); 71 skip_start (!okay, 2, "psLineInit. Expected NULL psLine input.\n"); 72 73 //Allocate a line and return true on Init 74 line = psLineAlloc(1); 75 okay = psLineInit(line); 76 ok( okay, "psLineInit. Expected true for valid psLine input.\n"); 77 skip_start( !okay, 1, "psLineInit. Expected true for valid psLine input."); 78 79 ok (line->NLINE == 1 && line->Nline == 0, 80 "psLineInit returned line parameters."); 81 82 skip_end(); 83 skip_end(); 84 85 psFree(line); 86 87 return 0; 88 } 56 // testLineAdd() 57 { 58 psMemId id = psMemGetId(); 59 psLine *line = NULL; 60 //Return false for NULL input 61 ok(!psLineAdd(line, "Hello World"), 62 "psLineAdd. Expected false for NULL psLine input."); 63 //Allocate and return true for valid input. 64 line = psLineAlloc(20); 65 int okay = psLineAdd(line, "Hello %s", "World"); 66 ok( okay, "psLineAdd. Expected true for valid psLine input"); 67 ok(line->NLINE == 20 && line->Nline == 11, 68 "psLineAdd failed to return the correct line parameters"); 69 ok(!strncmp(line->line, "Hello World", 20), 70 "psLineAdd failed to store the correct line string."); 71 psFree(line); 72 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 73 } 89 74 90 75 91 psS32 testLineAdd(void) 92 { 93 // diag("testLineAdd"); 94 95 psLine *line = NULL; 96 //Return false for NULL input 97 ok (!psLineAdd(line, "Hello World"), 98 "psLineAdd. Expected false for NULL psLine input."); 99 skip_start(psLineAdd(line, "Hello World"), 100 3, "psLineAdd. Expected false for NULL psLine input."); 101 102 //Allocate and return true for valid input. 103 line = psLineAlloc(20); 104 int okay = psLineAdd(line, "Hello %s", "World"); 105 ok( okay, "psLineAdd. Expected true for valid psLine input.\n"); 106 skip_start( !okay, 2, "psLineAdd.Expected true for valid psLine input.\n"); 107 108 ok (line->NLINE == 20 && line->Nline == 11, 109 "psLineAdd failed to return the correct line parameters.\n"); 110 skip_start (line->NLINE != 20 || line->Nline != 11, 111 1,"psLineAdd failed to return the correct line parameters.\n"); 112 113 ok (!strncmp(line->line, "Hello World", 20), 114 "psLineAdd failed to store the correct line string."); 115 116 skip_end(); 117 skip_end(); 118 skip_end(); 119 120 psFree(line); 121 122 return 0; 76 // testLineChk() 77 { 78 psMemId id = psMemGetId(); 79 psLine *line = NULL; 80 //Return false for Null input line 81 ok(!psMemCheckLine(line), 82 "psMemCheckLine return false for NULL line input"); 83 line = psLineAlloc(1); 84 ok(psMemCheckLine(line), 85 "psMemCheckLine return true for valid line input"); 86 psFree(line); 87 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 88 } 123 89 } 124 125 psS32 testLineChk(void)126 {127 // diag("testLineChk");128 129 psLine *line = NULL;130 //Return false for Null input line131 ok (!psMemCheckLine(line),132 "psMemCheckLine return false for NULL line input.\n");133 skip_start (psMemCheckLine(line),134 1, "psMemCheckLine return false for NULL line input.\n");135 136 line = psLineAlloc(1);137 ok (psMemCheckLine(line),138 "psMemCheckLine return true for valid line input.\n");139 140 psFree(line);141 142 skip_end();143 144 return 0;145 }
Note:
See TracChangeset
for help on using the changeset viewer.
