//============================================================================== // // Copyright (C) 2002 Dick van Oudheusden // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this program; if not, write to the Free // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // //============================================================================== // // $Date: 2003/11/27 21:18:53 $ $Revision: 1.2 $ // //============================================================================== #include #include "ofc/config.h" #include "ofc/DTable.h" #include "DInc.h" #include "DTest.h" //-Collections----------------------------------------------------------------- void DTable_test() { DTable *table1 = [[DTable alloc] init]; DTable *table2 = [DTable alloc]; DInc *test; long r,c; STARTTEST(); [table2 init :10 :5]; TEST([table1 isValid :0 :0]); TEST(![table1 isValid :1 :1]); TEST([table2 isValid :0 :0]); TEST([table2 isValid :9 :4]); TEST(![table2 isValid :10 :5]); TEST([table2 length ] == 50); TEST([table2 rows ] == 5 ); TEST([table2 columns] == 10); [DInc reset]; for (c = 0; c < [table2 columns]; c++) for (r = 0; r < [table2 rows]; r++) { [table2 set :c :r :[DInc new]]; } TEST([[table2 columns :20] columns] == 20); test = [table2 get :5 :3]; TEST([test number] == 29); // 5 * rows + 3 + 1 TEST(![table2 has :[DInc new]]); TEST( [table2 has :test]); [table2 set :11 :0 :test]; TEST([table2 count :test] == 2); [table2 set :11 :0 :nil]; TEST([table2 count :test] == 1); [table2 free]; [table1 free]; STOPTEST(); }