xref: /aoo41x/main/sal/qa/rtl/random/rtl_random.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
30*cdf0e10cSrcweir #include "precompiled_sal.hxx"
31*cdf0e10cSrcweir // autogenerated file with codegen.pl
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <algorithm> // STL
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <testshl/simpleheader.hxx>
36*cdf0e10cSrcweir #include <rtl/random.h>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir namespace rtl_random
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir class createPool : public CppUnit::TestFixture
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir public:
44*cdf0e10cSrcweir     // initialise your test code values here.
45*cdf0e10cSrcweir     void setUp()
46*cdf0e10cSrcweir     {
47*cdf0e10cSrcweir     }
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir     void tearDown()
50*cdf0e10cSrcweir     {
51*cdf0e10cSrcweir     }
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     // insert your test code here.
54*cdf0e10cSrcweir     // this is only demonstration code
55*cdf0e10cSrcweir     void createPool_001()
56*cdf0e10cSrcweir     {
57*cdf0e10cSrcweir         // this is demonstration code
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir         // LLA: seems to be that an other test is not possible for createPool()
62*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("create failed", aPool != NULL);
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
65*cdf0e10cSrcweir     }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir     // Change the following lines only, if you add, remove or rename
68*cdf0e10cSrcweir     // member functions of the current class,
69*cdf0e10cSrcweir     // because these macros are need by auto register mechanism.
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(createPool);
72*cdf0e10cSrcweir     CPPUNIT_TEST(createPool_001);
73*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
74*cdf0e10cSrcweir }; // class createPool
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir class destroyPool : public CppUnit::TestFixture
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir public:
80*cdf0e10cSrcweir     // initialise your test code values here.
81*cdf0e10cSrcweir     void setUp()
82*cdf0e10cSrcweir     {
83*cdf0e10cSrcweir     }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     void tearDown()
86*cdf0e10cSrcweir     {
87*cdf0e10cSrcweir     }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     // insert your test code here.
90*cdf0e10cSrcweir     void destroyPool_000()
91*cdf0e10cSrcweir     {
92*cdf0e10cSrcweir         // GPF, if failed
93*cdf0e10cSrcweir         rtl_random_destroyPool(NULL);
94*cdf0e10cSrcweir     }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     void destroyPool_001()
97*cdf0e10cSrcweir     {
98*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir         // LLA: seems to be that an other test is not possible for createPool()
101*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("create failed", aPool != NULL);
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
104*cdf0e10cSrcweir     }
105*cdf0e10cSrcweir     // Change the following lines only, if you add, remove or rename
106*cdf0e10cSrcweir     // member functions of the current class,
107*cdf0e10cSrcweir     // because these macros are need by auto register mechanism.
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(destroyPool);
110*cdf0e10cSrcweir     CPPUNIT_TEST(destroyPool_000);
111*cdf0e10cSrcweir     CPPUNIT_TEST(destroyPool_001);
112*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
113*cdf0e10cSrcweir }; // class destroyPool
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir class addBytes : public CppUnit::TestFixture
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir public:
119*cdf0e10cSrcweir     // initialise your test code values here.
120*cdf0e10cSrcweir     void setUp()
121*cdf0e10cSrcweir     {
122*cdf0e10cSrcweir     }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     void tearDown()
125*cdf0e10cSrcweir     {
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     // insert your test code here.
129*cdf0e10cSrcweir     // this is only demonstration code
130*cdf0e10cSrcweir     void addBytes_000()
131*cdf0e10cSrcweir     {
132*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         sal_uInt32  nBufLen = 4;
135*cdf0e10cSrcweir         sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
136*cdf0e10cSrcweir         memset(pBuffer, 0, nBufLen);
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         rtlRandomError aError = rtl_random_addBytes(NULL, NULL, 0);
139*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_Argument);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir         /* rtlRandomError */ aError = rtl_random_addBytes(aPool, NULL, 0);
142*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_Argument);
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir         /* rtlRandomError */ aError = rtl_random_addBytes(aPool, pBuffer, nBufLen);
145*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
148*cdf0e10cSrcweir         delete [] pBuffer;
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     void addBytes_001()
153*cdf0e10cSrcweir         {
154*cdf0e10cSrcweir             rtlRandomPool aPool = rtl_random_createPool();
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir             sal_uInt32  nBufLen = 4;
157*cdf0e10cSrcweir             sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir             memset(pBuffer, 0, nBufLen);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir             rtl_random_addBytes(aPool, pBuffer, nBufLen);
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir             t_print("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir             rtl_random_destroyPool(aPool);
166*cdf0e10cSrcweir             delete [] pBuffer;
167*cdf0e10cSrcweir         }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     // Change the following lines only, if you add, remove or rename
171*cdf0e10cSrcweir     // member functions of the current class,
172*cdf0e10cSrcweir     // because these macros are need by auto register mechanism.
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(addBytes);
175*cdf0e10cSrcweir     CPPUNIT_TEST(addBytes_000);
176*cdf0e10cSrcweir     CPPUNIT_TEST(addBytes_001);
177*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
178*cdf0e10cSrcweir }; // class addBytes
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir class Statistics
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     int m_nDispensation[256];
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     int m_nMin;
186*cdf0e10cSrcweir     int m_nMax;
187*cdf0e10cSrcweir     int m_nAverage;
188*cdf0e10cSrcweir     int m_nMinDeviation;
189*cdf0e10cSrcweir     int m_nMaxDeviation;
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir public:
192*cdf0e10cSrcweir     void clearDispensation()
193*cdf0e10cSrcweir         {
194*cdf0e10cSrcweir             for (int i = 0;i < 256;i ++)                        // clear array
195*cdf0e10cSrcweir             {
196*cdf0e10cSrcweir                 m_nDispensation[i] = 0;
197*cdf0e10cSrcweir             }
198*cdf0e10cSrcweir         }
199*cdf0e10cSrcweir     Statistics()
200*cdf0e10cSrcweir         {
201*cdf0e10cSrcweir             clearDispensation();
202*cdf0e10cSrcweir         }
203*cdf0e10cSrcweir     ~Statistics(){}
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir     void addValue(sal_Int16 _nIndex, sal_Int32 _nValue)
206*cdf0e10cSrcweir         {
207*cdf0e10cSrcweir             OSL_ASSERT(_nIndex >= 0 && _nIndex < 256);
208*cdf0e10cSrcweir             m_nDispensation[_nIndex] += _nValue;
209*cdf0e10cSrcweir         }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     void build(sal_Int32 _nCountMax)
212*cdf0e10cSrcweir         {
213*cdf0e10cSrcweir             m_nMin = _nCountMax;
214*cdf0e10cSrcweir             m_nMax = 0;
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir             m_nAverage = _nCountMax / 256;
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir             m_nMinDeviation = _nCountMax;
219*cdf0e10cSrcweir             m_nMaxDeviation = 0;
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir             for (int i = 0;i < 256;i ++)                        // show dispensation
222*cdf0e10cSrcweir             {
223*cdf0e10cSrcweir                 m_nMin = std::min(m_nMin, m_nDispensation[i]);
224*cdf0e10cSrcweir                 m_nMax = std::max(m_nMax, m_nDispensation[i]);
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir                 m_nMinDeviation = std::min(m_nMinDeviation, abs(m_nAverage - m_nDispensation[i]));
227*cdf0e10cSrcweir                 m_nMaxDeviation = std::max(m_nMaxDeviation, abs(m_nAverage - m_nDispensation[i]));
228*cdf0e10cSrcweir             }
229*cdf0e10cSrcweir         }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir     void print()
232*cdf0e10cSrcweir         {
233*cdf0e10cSrcweir             // LLA: these are only info values
234*cdf0e10cSrcweir             t_print("\nSome statistics\n");
235*cdf0e10cSrcweir             t_print("Min: %d\n", m_nMin);
236*cdf0e10cSrcweir             t_print("Max: %d\n", m_nMax);
237*cdf0e10cSrcweir             t_print("Average: %d\n", m_nAverage);
238*cdf0e10cSrcweir             t_print("Min abs deviation: %d\n", m_nMinDeviation);
239*cdf0e10cSrcweir             t_print("Max abs deviation: %d\n", m_nMaxDeviation);
240*cdf0e10cSrcweir         }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir     sal_Int32 getAverage() {return m_nAverage;}
243*cdf0e10cSrcweir     sal_Int32 getMaxDeviation() {return m_nMaxDeviation;}
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir };
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir class getBytes : public CppUnit::TestFixture
248*cdf0e10cSrcweir {
249*cdf0e10cSrcweir public:
250*cdf0e10cSrcweir     // initialise your test code values here.
251*cdf0e10cSrcweir     void setUp()
252*cdf0e10cSrcweir     {
253*cdf0e10cSrcweir     }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     void tearDown()
256*cdf0e10cSrcweir     {
257*cdf0e10cSrcweir     }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir     // insert your test code here.
260*cdf0e10cSrcweir     void getBytes_000()
261*cdf0e10cSrcweir     {
262*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         sal_uInt32  nBufLen = 4;
265*cdf0e10cSrcweir         sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
266*cdf0e10cSrcweir         memset(pBuffer, 0, nBufLen);
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir         rtlRandomError aError = rtl_random_getBytes(NULL, NULL, 0);
269*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_Argument);
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir         /* rtlRandomError */ aError = rtl_random_getBytes(aPool, NULL, 0);
272*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_Argument);
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir         /* rtlRandomError */ aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
275*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
278*cdf0e10cSrcweir         delete [] pBuffer;
279*cdf0e10cSrcweir     }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     void getBytes_001()
282*cdf0e10cSrcweir     {
283*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir         sal_uInt32  nBufLen = 4;
286*cdf0e10cSrcweir         sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
287*cdf0e10cSrcweir         memset(pBuffer, 0, nBufLen);
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir         rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
290*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir         t_print("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
295*cdf0e10cSrcweir         delete [] pBuffer;
296*cdf0e10cSrcweir     }
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     void getBytes_002()
299*cdf0e10cSrcweir     {
300*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         sal_uInt32  nBufLen = 4;
303*cdf0e10cSrcweir         sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen << 1 ];
304*cdf0e10cSrcweir         memset(pBuffer, 0, nBufLen << 1);
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("memset failed", pBuffer[4] == 0 && pBuffer[5] == 0 && pBuffer[6] == 0 && pBuffer[7] == 0);
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir         rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
309*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir         t_print("%2x %2x %2x %2x %2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3], pBuffer[4], pBuffer[5], pBuffer[6], pBuffer[7]);
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("internal memory overwrite", pBuffer[4] == 0 && pBuffer[5] == 0 && pBuffer[6] == 0 && pBuffer[7] == 0);
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
316*cdf0e10cSrcweir         delete [] pBuffer;
317*cdf0e10cSrcweir     }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir     void getBytes_003()
320*cdf0e10cSrcweir     {
321*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir         sal_uInt32  nBufLen = 1;
324*cdf0e10cSrcweir         sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
325*cdf0e10cSrcweir         memset(pBuffer, 0, nBufLen);
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir         Statistics aStat;
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("memset failed", pBuffer[0] == 0);
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir         int nCount = 0;
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir         int nCountMax = 1000000;
334*cdf0e10cSrcweir         for(nCount = 0;nCount < nCountMax; nCount ++)                  // run 100000000 through getBytes(...)
335*cdf0e10cSrcweir         {
336*cdf0e10cSrcweir             /* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer, nBufLen);
337*cdf0e10cSrcweir             /* CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None); */
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir             aStat.addValue(pBuffer[0], 1);
340*cdf0e10cSrcweir         }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir         aStat.build(nCountMax);
343*cdf0e10cSrcweir         aStat.print();
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("deviation should be less average", aStat.getMaxDeviation() < aStat.getAverage());
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
348*cdf0e10cSrcweir         delete [] pBuffer;
349*cdf0e10cSrcweir     }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir     void getBytes_003_1()
352*cdf0e10cSrcweir     {
353*cdf0e10cSrcweir         rtlRandomPool aPool = rtl_random_createPool();
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir         sal_uInt32  nBufLen = 256;
356*cdf0e10cSrcweir         sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
357*cdf0e10cSrcweir         memset(pBuffer, 0, nBufLen);
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         Statistics aStat;
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("memset failed", pBuffer[0] == 0);
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir         int nCount = 0;
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir         int nCountMax = 10000;
366*cdf0e10cSrcweir         for(nCount = 0;nCount < nCountMax; nCount ++)                  // run 100000000 through getBytes(...)
367*cdf0e10cSrcweir         {
368*cdf0e10cSrcweir             /* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer, nBufLen);
369*cdf0e10cSrcweir             // CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir             for (sal_uInt32 i=0;i<nBufLen;i++)
372*cdf0e10cSrcweir             {
373*cdf0e10cSrcweir                 aStat.addValue(pBuffer[i], 1);
374*cdf0e10cSrcweir             }
375*cdf0e10cSrcweir         }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir         aStat.build(nCountMax * nBufLen);
378*cdf0e10cSrcweir         aStat.print();
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE("deviation should be less average", aStat.getMaxDeviation() < aStat.getAverage());
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir         rtl_random_destroyPool(aPool);
383*cdf0e10cSrcweir         delete [] pBuffer;
384*cdf0e10cSrcweir     }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir     // Change the following lines only, if you add, remove or rename
387*cdf0e10cSrcweir     // member functions of the current class,
388*cdf0e10cSrcweir     // because these macros are need by auto register mechanism.
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(getBytes);
391*cdf0e10cSrcweir     CPPUNIT_TEST(getBytes_000);
392*cdf0e10cSrcweir     CPPUNIT_TEST(getBytes_001);
393*cdf0e10cSrcweir     CPPUNIT_TEST(getBytes_002);
394*cdf0e10cSrcweir     CPPUNIT_TEST(getBytes_003);
395*cdf0e10cSrcweir     CPPUNIT_TEST(getBytes_003_1);
396*cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
397*cdf0e10cSrcweir }; // class getBytes
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir // -----------------------------------------------------------------------------
400*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::createPool, "rtl_random");
401*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::destroyPool, "rtl_random");
402*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::addBytes, "rtl_random");
403*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::getBytes, "rtl_random");
404*cdf0e10cSrcweir } // namespace rtl_random
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir // -----------------------------------------------------------------------------
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir // this macro creates an empty function, which will called by the RegisterAllFunctions()
410*cdf0e10cSrcweir // to let the user the possibility to also register some functions by hand.
411*cdf0e10cSrcweir NOADDITIONAL;
412*cdf0e10cSrcweir 
413