/[resiprocate]/main/sip/resiprocate/test/testRandomHex.cxx
ViewVC logotype

Contents of /main/sip/resiprocate/test/testRandomHex.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 485 - (show annotations) (download)
Wed Nov 6 02:32:53 2002 UTC (17 years, 2 months ago) by derekm
File size: 1068 byte(s)
*** empty log message ***

1
2 #include <iostream>
3 #include <set>
4
5 #include <util/Data.hxx>
6 #include <util/RandomHex.hxx>
7
8 using namespace std;
9 using namespace Vocal2;
10
11 int main(int argc, char** argv)
12 {
13 if(argc != 3)
14 {
15 cerr << "usage: testRandomHex number_of_tries string_length" << endl;
16 exit(-1);
17 }
18
19 int runs = atoi(argv[1]);
20 int length = atoi(argv[2]);
21
22 if (runs <= 0 || length <= 0)
23 {
24 cerr << "usage: testRandomHex number_of_tries string_length" << endl
25 << "number_of_tries and string_length must be a positive integers." << endl;
26 exit(-1);
27 }
28
29 cerr << "Generating " << runs << " random " << length << " byte strings and checking for uniqueness." << endl;
30
31 set<Data> randomDatas;
32
33 for (int i = 0; i < runs; i++)
34 {
35 Data foo = RandomHex::get(length);
36 // cerr << foo << endl;
37 if (randomDatas.insert(foo).second == false)
38 {
39 cerr << "RandomHex produced a duplicate" << length << "byte string after " << i << " runs. " << endl;
40 exit(-1);
41 }
42 }
43 cerr << "Success." << endl;
44 }
45
46

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27