//============================================================================== // // 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/10/31 08:12:35 $ $Revision: 1.1 $ // //============================================================================== #include #include "ofc/config.h" #include "ofc/DInt.h" #include "DInc.h" #include "DTest.h" //-DataTypes------------------------------------------------------------------- void DInt_test() { DInt *i = [[DInt alloc] init]; DInt *c = [[DInt alloc] init]; char t[] = "8912%"; char w[] = "(45)"; // wrong.. char *pt; STARTTEST(); TEST([i get] == 0); TEST([[i set :7] get] == 7); TEST([[i toText] ccompare :"7"] == 0); [c set :-4]; TEST([i compare :c] == 1); TEST([c compare :i] == -1); if (sizeof(int) == 2) { [i set :0x1234]; TEST([i toBigEndian ] == 0x3412); TEST([i toLittleEndian] == 0x1234); } else if (sizeof(int) == 4) { [i set :0x12345678]; TEST([i toBigEndian ] == 0x78563412); TEST([i toLittleEndian] == 0x12345678); } pt = t; TEST([i fromString :&pt] == 0); TEST([i get] == 8912); TEST(*pt == '%'); pt = w; TEST([i fromString :&pt] == ENODATA); STOPTEST(); }