00001 #ifndef __J2K__Test__ListTest_CPP__
00002 #define __J2K__Test__ListTest_CPP__
00003
00004 #include <j2k/Fred/Standard.hpp>
00005
00006 void test()
00007 {
00008 List L1;
00009 List L2;
00010 List L3;
00011
00012 L2.append(10);
00013
00014 L2.display();
00015
00016 L2.insert(20);
00017 L2.prev();
00018 L2.append(15);
00019
00020 L2.display();
00021
00022 L1.setFirst();
00023 L1.display();
00024 L1.insert( 39 );
00025 L1.next();
00026 L1.insert(12);
00027 L1.append(5);
00028 L1.prev();
00029 L1.insert(4);
00030 L1.display();
00031 L1.append(3);
00032 L1.append(2);
00033 L1.append(1);
00034 L1.display();
00035
00036 L2.setFirst();
00037 L2.find(20);
00038
00039 if ( L2.isInList() )
00040 {
00041 printf( "L2 curr: \t" );
00042 printf( "%d\n", L2.currValue() );
00043 }
00044 else
00045 {
00046 printf( "Odd - what happened to 20?\n" );
00047 }
00048
00049 printf( "L1: \n" );
00050 L1.display();
00051
00052 printf( "Size: %d \nL2:\n", L2.length() );
00053 L2.display();
00054
00055 printf( "L3: \n" );
00056 L3.display();
00057
00058 L1.setFirst();
00059 printf( "L1: \n" );
00060 L1.display();
00061
00062 if ( L1.find(20) > 0 )
00063 {
00064 printf( "Odd - shouldn't find 20 in L1!\n" );
00065 }
00066 else
00067 {
00068 printf( "20 not in L1.\n" );
00069 }
00070
00071 L1.setFirst();
00072 printf( "L1: \n" );
00073 L1.display();
00074
00075 if ( L1.find(5) > 0 )
00076 {
00077 printf( "%d @ %d\n", L1.currValue(), L1.getPos() );
00078 }
00079
00080 L2.setFirst();
00081 printf( "L2: \n" );
00082 L2.display();
00083
00084 if( L2.find(20) > 0 )
00085 {
00086 printf( "%d @ %d\n", L2.currValue(), L2.getPos() );
00087 }
00088 else
00089 {
00090 printf( "Didn't find it the first time\n" );
00091 }
00092
00093 L2.next();
00094
00095 if ( L2.find(20) > 0 )
00096 {
00097 printf( "Error: Found it again!\n" );
00098 printf( "%d @ %d\n", L2.currValue(), L2.getPos() );
00099 }
00100 else
00101 {
00102 printf( "Only once in list.\n" );
00103 }
00104
00105 L1.setFirst();
00106 printf( "L1: \n" );
00107 L1.display();
00108 printf( "%d @ %d\n", L1.currValue(), L1.getPos() );
00109
00110 L1.setValue(42);
00111
00112 printf( "L1: \n" );
00113 L1.display();
00114
00115 L2.setFirst();
00116 printf( "L2: \n" );
00117 L2.display();
00118
00119 printf( "\nRemoving: " );
00120 printf( "%d @ %d\n", L2.currValue(), L2.getPos() );
00121 printf( "%d\n", L2.remove() );
00122 printf( "%d @ %d\n", L2.currValue(), L2.getPos() );
00123
00124 printf( "L2: \n" );
00125 L2.display();
00126
00127 printf( "\nRemoving: " );
00128 printf( "%d @ %d\n", L2.currValue(), L2.getPos() );
00129 printf( "%d\n", L2.remove() );
00130 printf( "%d @ %d\n", L2.currValue(), L2.getPos() );
00131
00132 printf( "L2: \n" );
00133 L2.display();
00134
00135 printf( "Size: %d \n", L2.length() );
00136 L2.clear();
00137 printf( "L2: \n" );
00138 L2.display();
00139
00140 printf( "Size: %d \n", L2.length() );
00141 L2.append(5);
00142 printf( "L2: \n" );
00143 L2.display();
00144
00145 printf( "Start a new round.\n" );
00146 L2.clear();
00147
00148 printf( "L2: \n" );
00149 L2.display();
00150
00151 L2.setFirst();
00152 L2.insert(1);
00153
00154 printf( "L2: \n" );
00155 L2.display();
00156
00157 L2.insert(2);
00158
00159 printf( "L2: \n" );
00160 L2.display();
00161
00162 L2.setPos(2);
00163 L2.insert(3);
00164
00165 printf( "L2: \n" );
00166 L2.display();
00167
00168 printf( "That is all.\n" );
00169 printf( "-----------------------\n" );
00170
00171 }
00172
00173 #endif // End of ListTest.cpp