3 #include "wx/longlong.h"
7 #if defined(__MWERKS__) && macintosh
12 static const unsigned wxLongLong_t NumberOfTests
= 100000l;
14 //using namespace std;
15 int oddbits(unsigned int number
);
17 int oddbits(unsigned int number
)
28 void random(long& hi
, unsigned long& lo
);
30 void random(long& hi
, unsigned long& lo
)
35 for (int i
= 0; i
< 32; i
++)
37 hi
|= oddbits(rand()) << i
;
38 lo
|= oddbits(rand()) << i
;
46 cout
<< endl
<< "Starting shift tests." << endl
;
51 unsigned wxLongLong_t counter
= 0;
53 while (counter
< NumberOfTests
)
55 if ((counter
% 1000) == 999)
58 #if defined(__MWERKS__) && macintosh
59 GetNextEvent(0, NULL
);
64 wxLongLongWx
l1a(hi
, lo
);
65 wxLongLongWx
l1c(hi
, lo
);
67 wxLongLongNative
l2a(hi
, lo
);
68 wxLongLongNative
l2c(hi
, lo
);
71 int shift
= rand() % 64;
72 int leftshift
= oddbits(rand());
89 void *oneb
= l1b
.asArray();
90 void *twob
= l2b
.asArray();
91 void *onec
= l1c
.asArray();
92 void *twoc
= l2c
.asArray();
94 if ((memcmp(oneb
, twob
, 8) != 0) || (memcmp(onec
, twoc
, 8) != 0) || (memcmp(oneb
, onec
, 8) != 0))
96 cout
<< endl
<< "After " << wxLongLongNative(counter
) << " successful trials: " << endl
;
103 cout
<< shift
<< endl
;
113 cout
<< endl
<< wxLongLongNative(counter
) << " successful trial" << (counter
== 1 ? "." : "s.") << endl
;
122 cout
<< endl
<< "Starting first addition tests." << endl
;
125 unsigned long lo
= 0;
127 unsigned wxLongLong_t counter
= 0;
129 while (counter
< NumberOfTests
)
131 if ((counter
% 1000) == 999)
134 #if defined(__MWERKS__) && macintosh
135 GetNextEvent(0, NULL
);
140 wxLongLongWx
l1a(hi
, lo
);
141 wxLongLongNative
l2a(hi
, lo
);
142 wxLongLongWx
l1d(hi
, lo
);
143 wxLongLongNative
l2d(hi
, lo
);
145 wxLongLongWx
l1b(hi
, lo
);
146 wxLongLongNative
l2b(hi
, lo
);
148 wxLongLongNative l2c
;
155 void *onec
= l1c
.asArray();
156 void *twoc
= l2c
.asArray();
157 void *oned
= l1d
.asArray();
158 void *twod
= l2d
.asArray();
160 if ((memcmp(onec
, twoc
, 8) != 0) || (memcmp(oned
, twod
, 8) != 0) || (memcmp(onec
, oned
, 8) != 0))
162 cout
<< endl
<< "After " << wxLongLongNative(counter
) << " successful trials: " << endl
;
174 cout
<< endl
<< wxLongLongNative(counter
) << " successful trial" << (counter
== 1 ? "." : "s.") << endl
;
184 cout << endl << "Starting second addition tests." << endl;
187 unsigned long lo = 0;
189 unsigned wxLongLong_t counter = 0;
191 while (counter < NumberOfTests)
193 if ((counter % 1000) == 999)
196 #if defined(__MWERKS__) && macintosh
197 GetNextEvent(0, NULL);
202 wxLongLongWx l1a(hi, lo);
203 wxLongLongNative l2a(hi, lo);
204 wxLongLongWx l1c(hi, lo);
205 wxLongLongNative l2c(hi, lo);
207 wxLongLongWx l1b(hi, lo);
208 wxLongLongNative l2b(hi, lo);
213 void *one = l1b.asArray();
214 void *two = l2b.asArray();
216 if (memcmp(one, two, 8) != 0)
218 cout << endl << "After " << counter << " successful trials: " << endl;
230 cout << endl << counter << " successful trial" << (counter == 1 ? "." : "s.") << endl;
240 cout
<< endl
<< "Starting first subtraction tests." << endl
;
243 unsigned long lo
= 0;
245 unsigned wxLongLong_t counter
= 0;
247 while (counter
< NumberOfTests
)
249 if ((counter
% 1000) == 999)
252 #if defined(__MWERKS__) && macintosh
253 GetNextEvent(0, NULL
);
258 wxLongLongWx
l1a(hi
, lo
);
259 wxLongLongNative
l2a(hi
, lo
);
260 wxLongLongWx
l1d(hi
, lo
);
261 wxLongLongNative
l2d(hi
, lo
);
263 wxLongLongWx
l1b(hi
, lo
);
264 wxLongLongNative
l2b(hi
, lo
);
266 wxLongLongNative l2c
;
273 void *onec
= l1c
.asArray();
274 void *twoc
= l2c
.asArray();
275 void *oned
= l1d
.asArray();
276 void *twod
= l2d
.asArray();
278 if ((memcmp(onec
, twoc
, 8) != 0) || (memcmp(oned
, twod
, 8) != 0) || (memcmp(onec
, oned
, 8) != 0))
280 cout
<< endl
<< "After " << wxLongLongNative(counter
) << " successful trials: " << endl
;
294 cout
<< endl
<< wxLongLongNative(counter
) << " successful trial" << (counter
== 1 ? "." : "s.") << endl
;
304 cout << endl << "Starting second subtraction tests." << endl;
307 unsigned long lo = 0;
309 unsigned wxLongLong_t counter = 0;
311 while (counter < NumberOfTests)
313 if ((counter % 1000) == 999)
316 #if defined(__MWERKS__) && macintosh
317 GetNextEvent(0, NULL);
322 wxLongLongWx l1a(hi, lo);
323 wxLongLongNative l2a(hi, lo);
324 wxLongLongWx l1c(hi, lo);
325 wxLongLongNative l2c(hi, lo);
327 wxLongLongWx l1b(hi, lo);
328 wxLongLongNative l2b(hi, lo);
333 void *one = l1b.asArray();
334 void *two = l2b.asArray();
336 if (memcmp(one, two, 8) != 0)
338 cout << endl << "After " << counter << " successful trials: " << endl;
350 cout << endl << counter << " successful trial" << (counter == 1 ? "." : "s.") << endl;
361 cout
<< endl
<< "Starting pre/post increment/decrement tests." << endl
;
364 unsigned long lo
= 0;
366 unsigned wxLongLong_t counter
= 0;
368 while (counter
< NumberOfTests
)
370 if ((counter
% 1000) == 999)
373 #if defined(__MWERKS__) && macintosh
374 GetNextEvent(0, NULL
);
379 wxLongLongWx
l1a(hi
, lo
);
380 wxLongLongNative
l2a(hi
, lo
);
381 wxLongLongWx
l1b(hi
, lo
);
382 wxLongLongNative
l2b(hi
, lo
);
384 int increment
= oddbits(rand());
385 int pre
= oddbits(rand());
410 void *one
= l1b
.asArray();
411 void *two
= l2b
.asArray();
413 if (memcmp(one
, two
, 8) != 0)
415 cout
<< endl
<< "After " << wxLongLongNative(counter
) << " successful trials: " << endl
;
418 cout
<< (pre
? "pre" : "post") << (increment
? "increment" : "decrement") << endl
;
426 cout
<< endl
<< wxLongLongNative(counter
) << " successful trial" << (counter
== 1 ? "." : "s.") << endl
;
435 cout
<< endl
<< "Starting negation tests." << endl
;
438 unsigned long lo
= 0;
440 unsigned wxLongLong_t counter
= 0;
442 while (counter
< NumberOfTests
)
444 if ((counter
% 1000) == 999)
447 #if defined(__MWERKS__) && macintosh
448 GetNextEvent(0, NULL
);
453 wxLongLongWx
l1a(hi
, lo
);
454 wxLongLongNative
l2a(hi
, lo
);
455 wxLongLongWx
l1b(-l1a
);
456 wxLongLongNative
l2b(-l2a
);
458 void *one
= l1b
.asArray();
459 void *two
= l2b
.asArray();
461 if (memcmp(one
, two
, 8) != 0)
463 cout
<< endl
<< "After " << wxLongLongNative(counter
) << " successful trials: " << endl
;
473 cout
<< endl
<< wxLongLongNative(counter
) << " successful trial" << (counter
== 1 ? "." : "s.") << endl
;
478 int multiplicationtest();
480 int multiplicationtest()
482 cout
<< endl
<< "Starting multiplication tests." << endl
;
485 unsigned long lo
= 0;
487 unsigned wxLongLong_t counter
= 0;
489 while (counter
< NumberOfTests
)
491 if ((counter
% 1000) == 999)
494 #if defined(__MWERKS__) && macintosh
495 GetNextEvent(0, NULL
);
500 wxLongLongWx
l1a(hi
, lo
);
501 wxLongLongNative
l2a(hi
, lo
);
502 wxLongLongWx
l1d(hi
, lo
);
503 wxLongLongNative
l2d(hi
, lo
);
505 wxLongLongWx
l1b(hi
, lo
);
506 wxLongLongNative
l2b(hi
, lo
);
508 wxLongLongWx
l1c(l1a
* l1b
);
509 wxLongLongNative
l2c(l2a
* l2b
);
514 void *onec
= l1c
.asArray();
515 void *twoc
= l2c
.asArray();
516 void *oned
= l1c
.asArray();
517 void *twod
= l2c
.asArray();
519 if ((memcmp(onec
, twoc
, 8) != 0) || (memcmp(oned
, twod
, 8) != 0) || (memcmp(onec
, oned
, 8) != 0))
521 cout
<< endl
<< "After " << wxLongLongNative(counter
) << " successful trials: " << endl
;
535 cout
<< endl
<< wxLongLongNative(counter
) << " successful trial" << (counter
== 1 ? "." : "s.") << endl
;
544 cout
<< endl
<< "Starting bitwise tests." << endl
;
547 unsigned long lo
= 0;
549 unsigned wxLongLong_t counter
= 0;
551 while (counter
< NumberOfTests
)
553 if ((counter
% 1000) == 999)
556 #if defined(__MWERKS__) && macintosh
557 GetNextEvent(0, NULL
);
562 wxLongLongWx
l1a(hi
, lo
);
563 wxLongLongNative
l2a(hi
, lo
);
564 wxLongLongWx
l1d(hi
, lo
);
565 wxLongLongNative
l2d(hi
, lo
);
567 wxLongLongWx
l1b(hi
, lo
);
568 wxLongLongNative
l2b(hi
, lo
);
570 wxLongLongWx
l1c(l1a
* l1b
);
571 wxLongLongNative
l2c(l2a
* l2b
);
576 void *onec
= l1c
.asArray();
577 void *twoc
= l2c
.asArray();
578 void *oned
= l1c
.asArray();
579 void *twod
= l2c
.asArray();
581 if ((memcmp(onec
, twoc
, 8) != 0) || (memcmp(oned
, twod
, 8) != 0) || (memcmp(onec
, oned
, 8) != 0))
583 cout
<< endl
<< "After " << wxLongLongNative(counter
) << " successful trials: " << endl
;
597 cout
<< endl
<< wxLongLongNative(counter
) << " successful trial" << (counter
== 1 ? "." : "s.") << endl
;
604 #if defined(__MWERKS__) && macintosh
605 SIOUXSettings
.asktosaveonclose
= 0;
606 SIOUXSettings
.showstatusline
= 1;
607 SIOUXSettings
.autocloseonquit
= 0;
610 cout
<< "Starting tests." << endl
;
612 #if defined(__MWERKS__) && macintosh
613 GetNextEvent(0, NULL
);
618 if (!multiplicationtest())
642 cout
<< endl
<< "The tests are finished." << endl
;