Changeset 948
- Timestamp:
- Jun 9, 2004, 9:51:08 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/collections/tst_psList.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/collections/tst_psList.c
r946 r948 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-09 19: 27:09$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-09 19:51:08 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 108 108 psListFree(list,PS_FREE); 109 109 110 if (psMemCheckLeaks(currentId,NULL, NULL) != 0) {110 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 111 111 psError(__func__,"Memory Leaks Detected"); 112 112 return 64; … … 121 121 int currentId = psMemGetId(); 122 122 psList* list = NULL; 123 int* data ;123 int* data = NULL; 124 124 125 125 psLogMsg(__func__,PS_LOG_INFO,"psListAdd shall add an element to list"); … … 135 135 */ 136 136 137 data = psAlloc(sizeof(int)); 138 *data = 1; 139 137 140 // 1. list is NULL (error) 138 141 list = psListAdd(NULL,data,PS_LIST_HEAD); … … 144 147 145 148 // 2. data is NULL (error, list should not grow) 146 data = psAlloc(sizeof(int));147 *data = 1;148 149 list = psListAlloc(data); 150 psFree(data); 149 151 if (list->size != 1) { 150 152 psError(__func__,"psListAlloc didn't create a list properly."); … … 163 165 *data = 2; 164 166 list = psListAdd(list,data,PS_LIST_HEAD); 165 167 psFree(data); 166 168 // verify that the size incremented 167 169 if (list->size != 2) { … … 179 181 *data = 3; 180 182 list = psListAdd(list,data,PS_LIST_TAIL); 181 183 psFree(data); 182 184 // verify that the size incremented 183 185 if (list->size != 3) { … … 202 204 data = psAlloc(sizeof(int)); 203 205 *data = 4; 204 205 206 psLogMsg(__func__,PS_LOG_INFO,"Following should warn with invalid insert location"); 206 207 list = psListAdd(list,data,-10); 208 psFree(data); 207 209 // verify that the size incremented 208 210 if (list->size != 4 || *(int*)list->head->data != 4) { … … 216 218 *data = 5; 217 219 list = psListAdd(list,data,1); 220 psFree(data); 218 221 // verify that the size incremented 219 222 if (list->size != 5 || *(int*)list->head->next->data != 5) { … … 226 229 *data = 6; 227 230 list = psListAdd(list,data,4); 231 psFree(data); 228 232 // verify that the size incremented 229 233 if (list->size != 6 || *(int *)list->head->next->next->next->next->data != 6) { … … 236 240 *data = 7; 237 241 list = psListAdd(list,data,2); 242 psFree(data); 238 243 // verify that the size incremented 239 244 if (list->size != 7 || *(int *)list->head->next->next->data != 7) { … … 247 252 psLogMsg(__func__,PS_LOG_INFO,"Following should be a warning."); 248 253 list = psListAdd(list,data,9); 254 psFree(data); 249 255 // verify that the size incremented 250 256 if (list->size != 8) { … … 256 262 psListFree(list, PS_FREE); 257 263 258 if (psMemCheckLeaks(currentId,NULL, NULL) != 0) {264 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 259 265 psError(__func__,"Memory Leaks Detected"); 260 266 return 64; … … 384 390 psListFree(list,PS_FREE); 385 391 386 if (psMemCheckLeaks(currentId,NULL, NULL) != 0) {392 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 387 393 psError(__func__,"Memory Leaks Detected"); 388 394 return 64; … … 624 630 psListFree(list,PS_FREE); 625 631 626 if (psMemCheckLeaks(currentId,NULL, NULL) != 0) {632 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 627 633 psError(__func__,"Memory Leaks Detected"); 628 634 return 64; … … 686 692 psListFree(list,PS_FREE); 687 693 688 if (psMemCheckLeaks(currentId,NULL, NULL) != 0) {694 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 689 695 psError(__func__,"Memory Leaks Detected"); 690 696 return 64; … … 703 709 } 704 710 705 list = psVectorTo Dlist(vec);711 list = psVectorToList(vec); 706 712 707 713 if (vec->n != 15 || list->size != 15) { … … 738 744 } 739 745 740 list = psVectorTo Dlist(NULL);746 list = psVectorToList(NULL); 741 747 if (list != NULL) { 742 psError(__func__,"psVectorTo Dlist didn't return NULL when given NULL");748 psError(__func__,"psVectorToList didn't return NULL when given NULL"); 743 749 return 1; 744 750 } … … 747 753 vec = psVectorAlloc(1,PS_TYPE_PTR); 748 754 vec->n = 0; 749 list = psVectorTo Dlist(vec);755 list = psVectorToList(vec); 750 756 if (list == NULL) { 751 psError(__func__,"psVectorTo Dlist didn't create an empty list from an "757 psError(__func__,"psVectorToList didn't create an empty list from an " 752 758 "empty vector."); 753 759 return 1; … … 759 765 vec = psListToVector(list); 760 766 if (vec == NULL) { 761 psError(__func__,"psVectorTo Dlist didn't create an empty vector from an "767 psError(__func__,"psVectorToList didn't create an empty vector from an " 762 768 "empty list."); 763 769 return 1; … … 766 772 psListFree(list,PS_FREE); 767 773 768 if (psMemCheckLeaks(currentId,NULL, NULL) != 0) {774 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 769 775 psError(__func__,"Memory Leaks Detected"); 770 776 return 64; … … 807 813 *data = lcv; 808 814 list = psListAdd(list,data,PS_LIST_TAIL); 809 ps MemDecrRefCounter(data);815 psFree(data); 810 816 } 811 817 … … 900 906 } 901 907 902 if (psMemCheckLeaks(currentId,NULL,NULL) != 0) { 908 psListFree(list,PS_FREE); 909 910 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 903 911 psError(__func__,"Memory Leaks Detected"); 904 912 return 64;
Note:
See TracChangeset
for help on using the changeset viewer.
