bdiv_u16.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. type
  2. { TUInt16Bit1Test }
  3. TUInt16Bit1Test = class(TUInt16DivTest)
  4. protected
  5. function GetDivisor: Word; override;
  6. procedure DoTestIteration(Iteration: Integer); override;
  7. public
  8. function TestTitle: shortstring; override;
  9. end;
  10. { TUInt16Bit1ModTest }
  11. TUInt16Bit1ModTest = class(TUInt16ModTest)
  12. protected
  13. function GetDivisor: Word; override;
  14. procedure DoTestIteration(Iteration: Integer); override;
  15. public
  16. function TestTitle: shortstring; override;
  17. end;
  18. { TUInt16Bit2Test }
  19. TUInt16Bit2Test = class(TUInt16DivTest)
  20. protected
  21. function GetDivisor: Word; override;
  22. procedure DoTestIteration(Iteration: Integer); override;
  23. public
  24. function TestTitle: shortstring; override;
  25. end;
  26. { TUInt16Bit2ModTest }
  27. TUInt16Bit2ModTest = class(TUInt16ModTest)
  28. protected
  29. function GetDivisor: Word; override;
  30. procedure DoTestIteration(Iteration: Integer); override;
  31. public
  32. function TestTitle: shortstring; override;
  33. end;
  34. { TUInt16Bit3Test }
  35. TUInt16Bit3Test = class(TUInt16DivTest)
  36. protected
  37. function GetDivisor: Word; override;
  38. procedure DoTestIteration(Iteration: Integer); override;
  39. public
  40. function TestTitle: shortstring; override;
  41. end;
  42. { TUInt16Bit3ModTest }
  43. TUInt16Bit3ModTest = class(TUInt16ModTest)
  44. protected
  45. function GetDivisor: Word; override;
  46. procedure DoTestIteration(Iteration: Integer); override;
  47. public
  48. function TestTitle: shortstring; override;
  49. end;
  50. { TUInt16Bit7Test }
  51. TUInt16Bit7Test = class(TUInt16DivTest)
  52. protected
  53. function GetDivisor: Word; override;
  54. procedure DoTestIteration(Iteration: Integer); override;
  55. public
  56. function TestTitle: shortstring; override;
  57. end;
  58. { TUInt16Bit7ModTest }
  59. TUInt16Bit7ModTest = class(TUInt16ModTest)
  60. protected
  61. function GetDivisor: Word; override;
  62. procedure DoTestIteration(Iteration: Integer); override;
  63. public
  64. function TestTitle: shortstring; override;
  65. end;
  66. { TUInt16Bit10Test }
  67. TUInt16Bit10Test = class(TUInt16DivTest)
  68. protected
  69. function GetDivisor: Word; override;
  70. procedure DoTestIteration(Iteration: Integer); override;
  71. public
  72. function TestTitle: shortstring; override;
  73. end;
  74. { TUInt16Bit10ModTest }
  75. TUInt16Bit10ModTest = class(TUInt16ModTest)
  76. protected
  77. function GetDivisor: Word; override;
  78. procedure DoTestIteration(Iteration: Integer); override;
  79. public
  80. function TestTitle: shortstring; override;
  81. end;
  82. { TUInt16Bit100Test }
  83. TUInt16Bit100Test = class(TUInt16DivTest)
  84. protected
  85. function GetDivisor: Word; override;
  86. procedure DoTestIteration(Iteration: Integer); override;
  87. public
  88. function TestTitle: shortstring; override;
  89. end;
  90. { TUInt16Bit100ModTest }
  91. TUInt16Bit100ModTest = class(TUInt16ModTest)
  92. protected
  93. function GetDivisor: Word; override;
  94. procedure DoTestIteration(Iteration: Integer); override;
  95. public
  96. function TestTitle: shortstring; override;
  97. end;
  98. { TUInt16Bit1000Test }
  99. const
  100. FU16_1000Input: array[$0..$F] of Word =
  101. (0, 1, 999, 1000, 1001, 1999, 2000, 2001,
  102. 64999, 65000, 65001,
  103. $7FFE, $7FFF, $8000, $8001, $FFFF);
  104. type
  105. TUInt16Bit1000Test = class(TUInt16DivTest)
  106. protected
  107. function GetDivisor: Word; override;
  108. procedure DoTestIteration(Iteration: Integer); override;
  109. public
  110. function TestTitle: shortstring; override;
  111. end;
  112. { TUInt16Bit1000ModTest }
  113. TUInt16Bit1000ModTest = class(TUInt16ModTest)
  114. protected
  115. function GetDivisor: Word; override;
  116. procedure DoTestIteration(Iteration: Integer); override;
  117. public
  118. function TestTitle: shortstring; override;
  119. end;
  120. { TUInt16Bit1Test }
  121. function TUInt16Bit1Test.TestTitle: shortstring;
  122. begin
  123. Result := 'Unsigned 16-bit division by 1';
  124. end;
  125. function TUInt16Bit1Test.GetDivisor: Word;
  126. begin
  127. Result := 1;
  128. end;
  129. procedure TUInt16Bit1Test.DoTestIteration(Iteration: Integer);
  130. var
  131. Numerator, Answer: Word;
  132. Index, X: Integer;
  133. begin
  134. Index := Iteration and $FF;
  135. case Index of
  136. 253:
  137. Numerator := 65533;
  138. 254:
  139. Numerator := 65534;
  140. 255:
  141. Numerator := 65535;
  142. else
  143. Numerator := Word(Index);
  144. end;
  145. FInputArray[Index] := Numerator;
  146. for X := 0 to INTERNAL_LOOPS - 1 do
  147. Answer := Numerator div 1;
  148. FResultArray[Index] := Answer;
  149. end;
  150. { TUInt16Bit1Test }
  151. function TUInt16Bit1ModTest.TestTitle: shortstring;
  152. begin
  153. Result := 'Unsigned 16-bit modulus by 1';
  154. end;
  155. function TUInt16Bit1ModTest.GetDivisor: Word;
  156. begin
  157. Result := 1;
  158. end;
  159. procedure TUInt16Bit1ModTest.DoTestIteration(Iteration: Integer);
  160. var
  161. Numerator, Answer: Word;
  162. Index, X: Integer;
  163. begin
  164. Index := Iteration and $FF;
  165. case Index of
  166. 253:
  167. Numerator := 65533;
  168. 254:
  169. Numerator := 65534;
  170. 255:
  171. Numerator := 65535;
  172. else
  173. Numerator := Word(Index);
  174. end;
  175. FInputArray[Index] := Numerator;
  176. for X := 0 to INTERNAL_LOOPS - 1 do
  177. Answer := Numerator mod 1;
  178. FResultArray[Index] := Answer;
  179. end;
  180. { TUInt16Bit2Test }
  181. function TUInt16Bit2Test.TestTitle: shortstring;
  182. begin
  183. Result := 'Unsigned 16-bit division by 2';
  184. end;
  185. function TUInt16Bit2Test.GetDivisor: Word;
  186. begin
  187. Result := 2;
  188. end;
  189. procedure TUInt16Bit2Test.DoTestIteration(Iteration: Integer);
  190. var
  191. Numerator, Answer: Word;
  192. Index, X: Integer;
  193. begin
  194. Index := Iteration and $FF;
  195. case Index of
  196. 253:
  197. Numerator := 65533;
  198. 254:
  199. Numerator := 65534;
  200. 255:
  201. Numerator := 65535;
  202. else
  203. Numerator := Word(Index);
  204. end;
  205. FInputArray[Index] := Numerator;
  206. for X := 0 to INTERNAL_LOOPS - 1 do
  207. Answer := Numerator div 2;
  208. FResultArray[Index] := Answer;
  209. end;
  210. { TUInt16Bit2ModTest }
  211. function TUInt16Bit2ModTest.TestTitle: shortstring;
  212. begin
  213. Result := 'Unsigned 16-bit modulus by 2';
  214. end;
  215. function TUInt16Bit2ModTest.GetDivisor: Word;
  216. begin
  217. Result := 2;
  218. end;
  219. procedure TUInt16Bit2ModTest.DoTestIteration(Iteration: Integer);
  220. var
  221. Numerator, Answer: Word;
  222. Index, X: Integer;
  223. begin
  224. Index := Iteration and $FF;
  225. case Index of
  226. 253:
  227. Numerator := 65533;
  228. 254:
  229. Numerator := 65534;
  230. 255:
  231. Numerator := 65535;
  232. else
  233. Numerator := Word(Index);
  234. end;
  235. FInputArray[Index] := Numerator;
  236. for X := 0 to INTERNAL_LOOPS - 1 do
  237. Answer := Numerator mod 2;
  238. FResultArray[Index] := Answer;
  239. end;
  240. { TUInt16Bit3Test }
  241. function TUInt16Bit3Test.TestTitle: shortstring;
  242. begin
  243. Result := 'Unsigned 16-bit division by 3';
  244. end;
  245. function TUInt16Bit3Test.GetDivisor: Word;
  246. begin
  247. Result := 3;
  248. end;
  249. procedure TUInt16Bit3Test.DoTestIteration(Iteration: Integer);
  250. var
  251. Numerator, Answer: Word;
  252. Index, X: Integer;
  253. begin
  254. Index := Iteration and $FF;
  255. case Index of
  256. 253:
  257. Numerator := 65533;
  258. 254:
  259. Numerator := 65534;
  260. 255:
  261. Numerator := 65535;
  262. else
  263. Numerator := Word(Index);
  264. end;
  265. FInputArray[Index] := Numerator;
  266. for X := 0 to INTERNAL_LOOPS - 1 do
  267. Answer := Numerator div 3;
  268. FResultArray[Index] := Answer;
  269. end;
  270. { TUInt16Bit3ModTest }
  271. function TUInt16Bit3ModTest.TestTitle: shortstring;
  272. begin
  273. Result := 'Unsigned 16-bit modulus by 3';
  274. end;
  275. function TUInt16Bit3ModTest.GetDivisor: Word;
  276. begin
  277. Result := 3;
  278. end;
  279. procedure TUInt16Bit3ModTest.DoTestIteration(Iteration: Integer);
  280. var
  281. Numerator, Answer: Word;
  282. Index, X: Integer;
  283. begin
  284. Index := Iteration and $FF;
  285. case Index of
  286. 253:
  287. Numerator := 65533;
  288. 254:
  289. Numerator := 65534;
  290. 255:
  291. Numerator := 65535;
  292. else
  293. Numerator := Word(Index);
  294. end;
  295. FInputArray[Index] := Numerator;
  296. for X := 0 to INTERNAL_LOOPS - 1 do
  297. Answer := Numerator mod 3;
  298. FResultArray[Index] := Answer;
  299. end;
  300. { TUInt16Bit7Test }
  301. function TUInt16Bit7Test.TestTitle: shortstring;
  302. begin
  303. Result := 'Unsigned 16-bit division by 7';
  304. end;
  305. function TUInt16Bit7Test.GetDivisor: Word;
  306. begin
  307. Result := 7;
  308. end;
  309. procedure TUInt16Bit7Test.DoTestIteration(Iteration: Integer);
  310. var
  311. Numerator, Answer: Word;
  312. Index, X: Integer;
  313. begin
  314. Index := Iteration and $FF;
  315. case Index of
  316. 253:
  317. Numerator := 65533;
  318. 254:
  319. Numerator := 65534;
  320. 255:
  321. Numerator := 65535;
  322. else
  323. Numerator := Word(Index);
  324. end;
  325. FInputArray[Index] := Numerator;
  326. for X := 0 to INTERNAL_LOOPS - 1 do
  327. Answer := Numerator div 7;
  328. FResultArray[Index] := Answer;
  329. end;
  330. { TUInt16Bit7ModTest }
  331. function TUInt16Bit7ModTest.TestTitle: shortstring;
  332. begin
  333. Result := 'Unsigned 16-bit modulus by 7';
  334. end;
  335. function TUInt16Bit7ModTest.GetDivisor: Word;
  336. begin
  337. Result := 7;
  338. end;
  339. procedure TUInt16Bit7ModTest.DoTestIteration(Iteration: Integer);
  340. var
  341. Numerator, Answer: Word;
  342. Index, X: Integer;
  343. begin
  344. Index := Iteration and $FF;
  345. case Index of
  346. 253:
  347. Numerator := 65533;
  348. 254:
  349. Numerator := 65534;
  350. 255:
  351. Numerator := 65535;
  352. else
  353. Numerator := Word(Index);
  354. end;
  355. FInputArray[Index] := Numerator;
  356. for X := 0 to INTERNAL_LOOPS - 1 do
  357. Answer := Numerator mod 7;
  358. FResultArray[Index] := Answer;
  359. end;
  360. { TUInt16Bit10Test }
  361. function TUInt16Bit10Test.TestTitle: shortstring;
  362. begin
  363. Result := 'Unsigned 16-bit division by 10';
  364. end;
  365. function TUInt16Bit10Test.GetDivisor: Word;
  366. begin
  367. Result := 10;
  368. end;
  369. procedure TUInt16Bit10Test.DoTestIteration(Iteration: Integer);
  370. var
  371. Numerator, Answer: Word;
  372. Index, X: Integer;
  373. begin
  374. Index := Iteration and $FF;
  375. case Index of
  376. 253:
  377. Numerator := 65533;
  378. 254:
  379. Numerator := 65534;
  380. 255:
  381. Numerator := 65535;
  382. else
  383. Numerator := Word(Index);
  384. end;
  385. FInputArray[Index] := Numerator;
  386. for X := 0 to INTERNAL_LOOPS - 1 do
  387. Answer := Numerator div 10;
  388. FResultArray[Index] := Answer;
  389. end;
  390. { TUInt16Bit10ModTest }
  391. function TUInt16Bit10ModTest.TestTitle: shortstring;
  392. begin
  393. Result := 'Unsigned 16-bit modulus by 10';
  394. end;
  395. function TUInt16Bit10ModTest.GetDivisor: Word;
  396. begin
  397. Result := 10;
  398. end;
  399. procedure TUInt16Bit10ModTest.DoTestIteration(Iteration: Integer);
  400. var
  401. Numerator, Answer: Word;
  402. Index, X: Integer;
  403. begin
  404. Index := Iteration and $FF;
  405. case Index of
  406. 253:
  407. Numerator := 65533;
  408. 254:
  409. Numerator := 65534;
  410. 255:
  411. Numerator := 65535;
  412. else
  413. Numerator := Word(Index);
  414. end;
  415. FInputArray[Index] := Numerator;
  416. for X := 0 to INTERNAL_LOOPS - 1 do
  417. Answer := Numerator mod 10;
  418. FResultArray[Index] := Answer;
  419. end;
  420. { TUInt16Bit100Test }
  421. function TUInt16Bit100Test.TestTitle: shortstring;
  422. begin
  423. Result := 'Unsigned 16-bit division by 100';
  424. end;
  425. function TUInt16Bit100Test.GetDivisor: Word;
  426. begin
  427. Result := 100;
  428. end;
  429. procedure TUInt16Bit100Test.DoTestIteration(Iteration: Integer);
  430. var
  431. Numerator, Answer: Word;
  432. Index, X: Integer;
  433. begin
  434. Index := Iteration and $FF;
  435. case Index of
  436. 253:
  437. Numerator := 65533;
  438. 254:
  439. Numerator := 65534;
  440. 255:
  441. Numerator := 65535;
  442. else
  443. Numerator := Word(Index);
  444. end;
  445. FInputArray[Index] := Numerator;
  446. for X := 0 to INTERNAL_LOOPS - 1 do
  447. Answer := Numerator div 100;
  448. FResultArray[Index] := Answer;
  449. end;
  450. { TUInt16Bit100ModTest }
  451. function TUInt16Bit100ModTest.TestTitle: shortstring;
  452. begin
  453. Result := 'Unsigned 16-bit modulus by 100';
  454. end;
  455. function TUInt16Bit100ModTest.GetDivisor: Word;
  456. begin
  457. Result := 100;
  458. end;
  459. procedure TUInt16Bit100ModTest.DoTestIteration(Iteration: Integer);
  460. var
  461. Numerator, Answer: Word;
  462. Index, X: Integer;
  463. begin
  464. Index := Iteration and $FF;
  465. case Index of
  466. 253:
  467. Numerator := 65533;
  468. 254:
  469. Numerator := 65534;
  470. 255:
  471. Numerator := 65535;
  472. else
  473. Numerator := Word(Index);
  474. end;
  475. FInputArray[Index] := Numerator;
  476. for X := 0 to INTERNAL_LOOPS - 1 do
  477. Answer := Numerator mod 100;
  478. FResultArray[Index] := Answer;
  479. end;
  480. { TUInt16Bit1000Test }
  481. function TUInt16Bit1000Test.TestTitle: shortstring;
  482. begin
  483. Result := 'Unsigned 16-bit division by 1,000';
  484. end;
  485. function TUInt16Bit1000Test.GetDivisor: Word;
  486. begin
  487. Result := 1000;
  488. end;
  489. procedure TUInt16Bit1000Test.DoTestIteration(Iteration: Integer);
  490. var
  491. Numerator, Answer: Word;
  492. Index, X: Integer;
  493. begin
  494. Index := Iteration and $FF;
  495. Numerator := FU16_1000Input[Index and $F];
  496. FInputArray[Index] := Numerator;
  497. for X := 0 to INTERNAL_LOOPS - 1 do
  498. Answer := Numerator div 1000;
  499. FResultArray[Index] := Answer;
  500. end;
  501. { TUInt16Bit1000ModTest }
  502. function TUInt16Bit1000ModTest.TestTitle: shortstring;
  503. begin
  504. Result := 'Unsigned 16-bit modulus by 1,000';
  505. end;
  506. function TUInt16Bit1000ModTest.GetDivisor: Word;
  507. begin
  508. Result := 1000;
  509. end;
  510. procedure TUInt16Bit1000ModTest.DoTestIteration(Iteration: Integer);
  511. var
  512. Numerator, Answer: Word;
  513. Index, X: Integer;
  514. begin
  515. Index := Iteration and $FF;
  516. Numerator := FU16_1000Input[Index and $F];
  517. FInputArray[Index] := Numerator;
  518. for X := 0 to INTERNAL_LOOPS - 1 do
  519. Answer := Numerator mod 1000;
  520. FResultArray[Index] := Answer;
  521. end;