/[ascend]/trunk/base/generic/general/test/test_list.c
ViewVC logotype

Diff of /trunk/base/generic/general/test/test_list.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 538 by johnpye, Fri Mar 31 08:52:57 2006 UTC revision 539 by johnpye, Tue Apr 25 23:11:59 2006 UTC
# Line 26  Line 26 
26  #include <stdarg.h>  #include <stdarg.h>
27  #include <utilities/ascConfig.h>  #include <utilities/ascConfig.h>
28  #include <utilities/ascMalloc.h>  #include <utilities/ascMalloc.h>
 #include <utilities/ascPrintType.h>  
29  #include <utilities/ascPrint.h>  #include <utilities/ascPrint.h>
30  #include <general/list.h>  #include <general/list.h>
31  #include "CUnit/CUnit.h"  #include "CUnit/CUnit.h"
# Line 148  static void test_list(void) Line 147  static void test_list(void)
147     *    1. pooling & recycling has been set up     *    1. pooling & recycling has been set up
148     *    2. the local gl_list_t* have been destroyed     *    2. the local gl_list_t* have been destroyed
149     *    3. pint_array[0..19] is allocated and initialized to [0..19]     *    3. pint_array[0..19] is allocated and initialized to [0..19]
150     *                                                                                 *
151     *  If a test section messes with any of these, then it must restore     *  If a test section messes with any of these, then it must restore
152     *  this state before finishing.     *  this state before finishing.
153     */     */
# Line 789  static void test_list(void) Line 788  static void test_list(void)
788    for (i=0 ; i<9 ; ++i) {    for (i=0 ; i<9 ; ++i) {
789      CU_TEST(*((unsigned long*)gl_fetch(p_list1, i+2)) >= *((unsigned long*)gl_fetch(p_list1, i+1)));      CU_TEST(*((unsigned long*)gl_fetch(p_list1, i+2)) >= *((unsigned long*)gl_fetch(p_list1, i+1)));
790    }    }
791      
792    for (i=0 ; i<10 ; ++i) {              /* fill the list with unsorted data again */    for (i=0 ; i<10 ; ++i) {              /* fill the list with unsorted data again */
793      gl_store(p_list1, i+1, pint_array[9-i]);      gl_store(p_list1, i+1, pint_array[9-i]);
794      CU_TEST(0 == gl_sorted(p_list1));      CU_TEST(0 == gl_sorted(p_list1));
# Line 1570  static void test_list(void) Line 1569  static void test_list(void)
1569    else {    else {
1570      CU_TEST(0 > gl_compare_ptrs(p_list1, p_list2));      CU_TEST(0 > gl_compare_ptrs(p_list1, p_list2));
1571    }    }
1572      
1573    gl_reset(p_list1);    gl_reset(p_list1);
1574    gl_reset(p_list2);    gl_reset(p_list2);
1575    
1576    for (i=0 ; i<20 ; ++i) {    for (i=0 ; i<20 ; ++i) {
1577      gl_append_ptr(p_list1, pint_array[i]);                                gl_append_ptr(p_list1, pint_array[i]);
1578      gl_append_ptr(p_list2, pint_array[i]);      gl_append_ptr(p_list2, pint_array[i]);
1579    }    }
1580      
1581    CU_TEST(0 == gl_compare_ptrs(p_list1, p_list2));   /* compare equal lists */    CU_TEST(0 == gl_compare_ptrs(p_list1, p_list2));   /* compare equal lists */
1582    CU_TEST(0 == gl_compare_ptrs(p_list2, p_list1));   /* compare equal lists */    CU_TEST(0 == gl_compare_ptrs(p_list2, p_list1));   /* compare equal lists */
1583    

Legend:
Removed from v.538  
changed lines
  Added in v.539

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22