Changeset 960
- Timestamp:
- Jun 9, 2004, 11:46:38 AM (22 years ago)
- Location:
- trunk/psLib/test/collections
- Files:
-
- 2 edited
-
tst_psList.c (modified) (4 diffs)
-
verified/tst_psList.stderr (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/collections/tst_psList.c
r953 r960 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-09 21: 20:53$8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-09 21:46:37 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 static int testListConvert(void); 25 25 static int testListIterator(void); 26 static int testListFree(void); 26 27 27 28 testDescription tests[] = { … … 32 33 {testListConvert,"491-testListConvert",0}, 33 34 {testListIterator,"494-testListIterator",0}, 35 {testListFree,"627-testListFree",0}, 34 36 {NULL} 35 37 }; … … 899 901 int testListFree(void) 900 902 { 903 float* data[15]; 904 psList* list; 901 905 902 906 /* 903 Call psDlistAlloc to create a doubly linked list. Create several data items and add them to the list. 904 Verify items are within the list. Verify the data item's reference counter are incremented after adding 905 to the list. Call psDlistFree with NULL specified as the elemFree function. Verify the list is 906 deallocated but not the data items. Verify the data item's reference counters are decremented by one 907 compared to when added to the list. 907 Call psDlistAlloc to create a doubly linked list. 908 909 Create several data items and add them to the list. 910 911 Verify the data item's reference counter are incremented after adding to the list. 912 (not really needed, as psListAdd is tested elsewhere) 908 913 */ 914 915 list = psListAlloc(NULL); 916 for (int lcv=0;lcv<15;lcv++) { 917 data[lcv] = psAlloc(sizeof(int)); 918 *data[lcv] = lcv; 919 list = psListAdd(list,data[lcv],PS_LIST_TAIL); 920 if (psMemGetRefCounter(data[lcv]) != 2) { 921 psError(__func__,"Reference counter for data was not incremented"); 922 return 1; 923 } 924 } 925 926 /* 927 Verify items are within the list. 928 (not needed, as psListAdd is tested elsewhere, but check anyway.) 929 */ 930 if (list->size != 15) { 931 psError(__func__,"List wasn't populated as expected?"); 932 return 2; 933 } 934 935 /* 936 Call psDlistFree with NULL specified as the elemFree function. 937 */ 938 939 psListFree(list,NULL); 940 941 /* 942 Verify the list is deallocated but not the data items. 943 (accomplished by checking for memory leaks) 944 945 Verify the data item's reference counters are decremented by one compared to when added to the list. 946 (technically, this could be accomplished by checking memory leaks too, but I checked anyway) 947 */ 948 949 for (int i=0;i<15;i++) { 950 if (psMemGetRefCounter(data[i]) != 1) { 951 psError(__func__,"pslistFree didn't decrement the data item's reference counter"); 952 return 3; 953 } 954 psFree(data[i]); 955 } 909 956 910 957 return 0; -
trunk/psLib/test/collections/verified/tst_psList.stderr
r953 r960 47 47 <DATE> <TIME> <HOST> |E|psListRemove |Couldn't position to given index (-2) to remove element from list. 48 48 <DATE> <TIME> <HOST> |I|testListRemove |Next message should be an error 49 <DATE> <TIME> <HOST> |E|psListRemove |Failed to find 0x0 on psList 0x6d 7f30 in psListRemove.49 <DATE> <TIME> <HOST> |E|psListRemove |Failed to find 0x0 on psList 0x6d8b90 in psListRemove. 50 50 <DATE> <TIME> <HOST> |I|testListRemove |Next message should be an error 51 <DATE> <TIME> <HOST> |E|psListRemove |Failed to find 0x6d 8840 on psList 0x6d7f30 in psListRemove.51 <DATE> <TIME> <HOST> |E|psListRemove |Failed to find 0x6d94a0 on psList 0x6d8b90 in psListRemove. 52 52 53 53 ---> TESTPOINT PASSED (psList{490-testListRemove} | tst_psList.c) … … 76 76 ---> TESTPOINT PASSED (psList{494-testListIterator} | tst_psList.c) 77 77 78 /----------------------------- TESTPOINT ------------------------------------------\ 79 | TestFile: tst_psList.c | 80 | TestPoint: psList{627-testListFree} | 81 | TestType: Positive | 82 \----------------------------------------------------------------------------------/ 83 84 85 ---> TESTPOINT PASSED (psList{627-testListFree} | tst_psList.c) 86
Note:
See TracChangeset
for help on using the changeset viewer.
