Changeset 1227 for trunk/psLib/test/collections
- Timestamp:
- Jul 15, 2004, 12:17:03 PM (22 years ago)
- Location:
- trunk/psLib/test/collections
- Files:
-
- 6 added
- 3 deleted
- 2 edited
-
Makefile (modified) (2 diffs)
-
tst_psArray (added)
-
tst_psArray.c (added)
-
tst_psList.c (modified) (4 diffs)
-
tst_psVector (added)
-
tst_psVector_01.c (deleted)
-
tst_psVector_02.c (deleted)
-
tst_psVector_03.c (deleted)
-
verified/tst_psArray.stdout (added)
-
verified/tst_psVector.stderr (added)
-
verified/tst_psVector.stdout (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/collections/Makefile
r1212 r1227 3 3 ## Makefile: test/collections 4 4 ## 5 ## $Revision: 1.1 8$ $Name: not supported by cvs2svn $6 ## $Date: 2004-07-1 3 01:37:58$5 ## $Revision: 1.19 $ $Name: not supported by cvs2svn $ 6 ## $Date: 2004-07-15 22:17:03 $ 7 7 ## 8 8 ## Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 19 19 LDFLAGS := -L../../lib -lpslib -lpstest $(LDFLAGS) 20 20 21 TARGET = tst_psVector_01 \ 22 tst_psVector_02 \ 23 tst_psVector_03 \ 21 TARGET = tst_psVector \ 22 tst_psArray \ 24 23 tst_psBitSet_01 \ 25 24 tst_psBitSet_02 \ -
trunk/psLib/test/collections/tst_psList.c
r1193 r1227 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-07- 08 01:05:01$8 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-15 22:17:03 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 686 686 687 687 psList* list = NULL; 688 ps Vector* vec= NULL;688 psArray* arr = NULL; 689 689 int* data; 690 690 … … 695 695 */ 696 696 697 // test dlist -> vector697 // test dlist -> array 698 698 699 699 // create a list … … 706 706 } 707 707 708 vec = psListToVector(list);709 710 if ( vec->n != 15 || list->size != 15) {711 psError(__func__,"The created vectordidn't have the proper size");712 return 1; 713 } 714 for (int i=0;i< vec->n;i++) {715 if (i != *(int*) vec->data.PTR[i]) {716 psError(__func__,"Element %d of vectoris incorrect (%d).",717 i,*(int*) vec->data.PTR[i]);708 arr = psListToArray(list); 709 710 if (arr->n != 15 || list->size != 15) { 711 psError(__func__,"The created array didn't have the proper size"); 712 return 1; 713 } 714 for (int i=0;i<arr->n;i++) { 715 if (i != *(int*)arr->data[i]) { 716 psError(__func__,"Element %d of array is incorrect (%d).", 717 i,*(int*)arr->data[i]); 718 718 return 1; 719 719 } 720 720 if (i != *(int*)psListGet(list,i)) { 721 721 psError(__func__,"Element %d of list is incorrect (%d).", 722 i,*(int*) vec->data.PTR[i]);722 i,*(int*)arr->data[i]); 723 723 return 1; 724 724 } 725 if (psMemGetRefCounter( vec->data.PTR[i]) != 2) {725 if (psMemGetRefCounter(arr->data[i]) != 2) { 726 726 psError(__func__,"Element %d had wrong reference count (%d).", 727 i,psMemGetRefCounter( vec->data.PTR[i]));727 i,psMemGetRefCounter(arr->data[i])); 728 728 return 1; 729 729 } 730 730 } 731 731 732 psFree( vec);733 psFree(list); 734 735 // test vector-> dlist736 737 // create a vector738 vec = psVectorAlloc(15,PS_TYPE_PTR);739 vec->n = vec->nalloc;732 psFree(arr); 733 psFree(list); 734 735 // test array -> dlist 736 737 // create an array 738 arr = psArrayAlloc(15); 739 arr->n = arr->nalloc; 740 740 for (int lcv=0;lcv<15;lcv++) { 741 741 data = psAlloc(sizeof(int)); 742 742 *data = lcv; 743 vec->data.PTR[lcv] = data;744 } 745 746 list = ps VectorToList(vec);747 748 if ( vec->n != 15 || list->size != 15) {749 psError(__func__,"The created vectordidn't have the proper size");750 return 1; 751 } 752 for (int i=0;i< vec->n;i++) {753 if (i != *(int*) vec->data.PTR[i]) {754 psError(__func__,"Element %d of vectoris incorrect (%d).",755 i,*(int*) vec->data.PTR[i]);743 arr->data[lcv] = data; 744 } 745 746 list = psArrayToList(arr); 747 748 if (arr->n != 15 || list->size != 15) { 749 psError(__func__,"The created array didn't have the proper size"); 750 return 1; 751 } 752 for (int i=0;i<arr->n;i++) { 753 if (i != *(int*)arr->data[i]) { 754 psError(__func__,"Element %d of array is incorrect (%d).", 755 i,*(int*)arr->data[i]); 756 756 return 1; 757 757 } 758 758 if (i != *(int*)psListGet(list,i)) { 759 759 psError(__func__,"Element %d of list is incorrect (%d).", 760 i,*(int*) vec->data.PTR[i]);760 i,*(int*)arr->data[i]); 761 761 return 1; 762 762 } 763 if (psMemGetRefCounter( vec->data.PTR[i]) != 2) {763 if (psMemGetRefCounter(arr->data[i]) != 2) { 764 764 psError(__func__,"Element %d had wrong reference count (%d).", 765 i,psMemGetRefCounter( vec->data.PTR[i]));765 i,psMemGetRefCounter(arr->data[i])); 766 766 return 1; 767 767 } 768 768 } 769 769 770 psFree( vec);771 psFree(list); 772 773 // now, make sure if input vector/list is NULL, output is NULL774 775 vec = psListToVector(NULL);776 if ( vec!= NULL) {777 psError(__func__,"psListTo Vectordidn't return NULL when given NULL");778 return 1; 779 } 780 781 list = ps VectorToList(NULL);770 psFree(arr); 771 psFree(list); 772 773 // now, make sure if input array/list is NULL, output is NULL 774 775 arr = psListToArray(NULL); 776 if (arr != NULL) { 777 psError(__func__,"psListToArray didn't return NULL when given NULL"); 778 return 1; 779 } 780 781 list = psArrayToList(NULL); 782 782 if (list != NULL) { 783 psError(__func__,"ps VectorToList didn't return NULL when given NULL");784 return 1; 785 } 786 787 // now, see what happens with a zero-size vector/list788 vec = psVectorAlloc(1,PS_TYPE_PTR);789 vec->n = 0;790 list = ps VectorToList(vec);783 psError(__func__,"psArrayToList didn't return NULL when given NULL"); 784 return 1; 785 } 786 787 // now, see what happens with a zero-size array/list 788 arr = psArrayAlloc(1); 789 arr->n = 0; 790 list = psArrayToList(arr); 791 791 if (list == NULL) { 792 psError(__func__,"ps VectorToList didn't create an empty list from an "793 "empty vector.");794 return 1; 795 } 796 psFree( vec);792 psError(__func__,"psArrayToList didn't create an empty list from an " 793 "empty array."); 794 return 1; 795 } 796 psFree(arr); 797 797 psFree(list); 798 798 799 799 list = psListAlloc(NULL); 800 vec = psListToVector(list);801 if ( vec== NULL) {802 psError(__func__,"ps VectorToList didn't create an empty vectorfrom an "800 arr = psListToArray(list); 801 if (arr == NULL) { 802 psError(__func__,"psArrayToList didn't create an empty array from an " 803 803 "empty list."); 804 804 return 1; 805 805 } 806 psFree( vec);806 psFree(arr); 807 807 psFree(list); 808 808
Note:
See TracChangeset
for help on using the changeset viewer.
