//============================================================================== // // Copyright (C) 2003 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/30 19:11:27 $ $Revision: 1.1 $ // //============================================================================== #include #include "ofc/config.h" #include "ofc/DLRnd.h" #include "DInc.h" #include "DTest.h" //-Misc------------------------------------------------------------------------ void DLRnd_test() { DLRnd *rnd = [DLRnd new]; int cnt; STARTTEST(); [rnd seed :2]; TEST([rnd nextInt] == 8454530); TEST([rnd nextInt] == -2129622665); TEST([rnd nextInt] == 1452347882); TEST([rnd nextInt] == -989988222); TEST([rnd nextInt] == 1497313164); TEST([rnd nextInt] == -528732117); TEST([rnd nextInt] == -1884346620); TEST([rnd nextInt] == -2045746177); TEST([rnd nextInt] == -1482939137); TEST([rnd nextInt] == 545984972); TEST([rnd nextInt] == -1451282524); TEST([rnd nextInt] == -487943499); TEST([rnd nextInt] == -54932054); TEST([rnd nextInt] == 2082605845); TEST([rnd nextInt] == -1287929040); TEST([rnd nextInt] == 410613174); TEST([rnd nextInt] == 925157095); TEST([rnd nextInt] == -523767072); TEST([rnd nextInt] == -1839610270); TEST([rnd nextInt] == -1927380191); TEST([rnd nextInt] == 1917675326); TEST([rnd nextInt] == 1867299163); TEST([rnd nextInt] == -707094351); TEST([rnd nextInt] == 2124052277); TEST([rnd nextInt] == 1744661982); TEST([rnd nextInt] == -907544543); TEST([rnd nextInt] == 581558353); TEST([rnd nextInt] == 489311608); TEST([rnd nextInt] == 2008985074); TEST([rnd nextInt] == 1306162804); TEST([rnd nextInt] == 1996517264); TEST([rnd nextInt] == -114676512); TEST([rnd nextInt] == 587089834); TEST([rnd nextInt] == 2116589310); TEST([rnd nextInt] == 1683114138); TEST([rnd nextInt] == 141114251); TEST([rnd nextInt] == -1987467723); TEST([rnd nextInt] == -1326090517); TEST([rnd nextInt] == 2046002867); TEST([rnd nextInt] == -466559862); TEST([rnd nextInt] == 591511397); TEST([rnd nextInt] == 1019947309); TEST([rnd nextInt] == 782596157); TEST([rnd nextInt] == -836368555); TEST([rnd nextInt] == 1851619346); TEST([rnd nextInt] == 1395902832); TEST([rnd nextInt] == -77620304); TEST([rnd nextInt] == -514278677); TEST([rnd nextInt] == 313686365); TEST([rnd nextLong] == -110527206); for (cnt = 0; cnt < 500; cnt++) { int val = [rnd nextInt :10 :30]; TEST((val >= 10) && (val <= 30)); } #if 0 for (cnt = 0; cnt < 50; cnt++) printf("%g,", [rnd nextDouble]); printf("\n"); #endif for (cnt = 0; cnt < 500; cnt++) { double val = [rnd nextDouble :12.4 :12.5]; TEST((val >= 12.4) && (val < 12.5)); } [rnd free]; STOPTEST(); }