[2] | 1 | #include "func_test.h" |
---|
| 2 | #include "func_array.h" |
---|
| 3 | #include "func_endianness.h" |
---|
| 4 | #include "func_factoriel.h" |
---|
| 5 | #include "func_fibonnacci.h" |
---|
| 6 | #include "func_hanoi.h" |
---|
| 7 | #include "func_integrity.h" |
---|
| 8 | #include "func_io.h" |
---|
| 9 | #include "func_math.h" |
---|
| 10 | #include "func_mm.h" |
---|
| 11 | #include "func_parite.h" |
---|
| 12 | #include "func_premier.h" |
---|
| 13 | #include "func_test.h" |
---|
| 14 | #include "func_test_io.h" |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | // mul_soft |
---|
| 18 | // div_soft |
---|
| 19 | // mul_hard |
---|
| 20 | // div_hard |
---|
| 21 | // modulo |
---|
| 22 | #define PARAM_06 30 // fibonnacci max : 43 |
---|
| 23 | #define PARAM_07 15 // n_premier max : 30 |
---|
| 24 | #define PARAM_08 100 // tri_croissant max : unlimited (200) |
---|
| 25 | #define PARAM_09 10 // hanoi max : 12 |
---|
| 26 | #define PARAM_10 15 // mul matrix max : unlimited (30) |
---|
| 27 | #define PARAM_11 12 // factoriel_rec max : 12 |
---|
| 28 | #define PARAM_12 12 // factoriel_it max : 12 |
---|
| 29 | #define PARAM_13 50 // parite max : unlimited (200) |
---|
| 30 | |
---|
| 31 | //---------------------------------- |
---|
| 32 | // TEST 1 |
---|
| 33 | // multiplication software |
---|
| 34 | //---------------------------------- |
---|
| 35 | int test_01 () |
---|
| 36 | { |
---|
| 37 | int op1, op2, wait, res, test1; |
---|
| 38 | #ifdef HAVE_LIBC |
---|
| 39 | printf("Test_01 - mult_soft\n"); |
---|
| 40 | #else |
---|
| 41 | print(0xABCD0001); |
---|
| 42 | #endif |
---|
| 43 | |
---|
| 44 | test1 = 1; |
---|
| 45 | { |
---|
| 46 | #ifdef HAVE_LIBC |
---|
| 47 | printf(" * Test_01a\n"); |
---|
| 48 | #else |
---|
| 49 | print(0xABCD001A); |
---|
| 50 | #endif |
---|
| 51 | |
---|
| 52 | op1 = 40; |
---|
| 53 | op2 = 17; |
---|
| 54 | wait = 680; // 0x2a8 |
---|
| 55 | res = mul_soft(op1,op2); |
---|
| 56 | |
---|
| 57 | print(res); |
---|
| 58 | test1 &= (wait == res); |
---|
| 59 | } |
---|
| 60 | { |
---|
| 61 | #ifdef HAVE_LIBC |
---|
| 62 | printf(" * Test_01b\n"); |
---|
| 63 | #else |
---|
| 64 | print(0xABCD001B); |
---|
| 65 | #endif |
---|
| 66 | |
---|
| 67 | op1 = 1569; |
---|
| 68 | op2 = 9835; |
---|
| 69 | wait = 15431115; // 0xEB75CB |
---|
| 70 | res = mul_soft(op1,op2); |
---|
| 71 | |
---|
| 72 | print(res); |
---|
| 73 | test1 &= (wait == res); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | return test1; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | //---------------------------------- |
---|
| 80 | // TEST 2 |
---|
| 81 | // division software |
---|
| 82 | //---------------------------------- |
---|
| 83 | int test_02 () |
---|
| 84 | { |
---|
| 85 | int op1, op2, wait, res, test2; |
---|
| 86 | #ifdef HAVE_LIBC |
---|
| 87 | printf("Test_02 - div_soft\n"); |
---|
| 88 | #else |
---|
| 89 | print(0xABCD0002); |
---|
| 90 | #endif |
---|
| 91 | |
---|
| 92 | test2 = 1; |
---|
| 93 | { |
---|
| 94 | #ifdef HAVE_LIBC |
---|
| 95 | printf(" * Test_02a\n"); |
---|
| 96 | #else |
---|
| 97 | print(0xABCD002A); |
---|
| 98 | #endif |
---|
| 99 | |
---|
| 100 | op1 = 680; |
---|
| 101 | op2 = 40; |
---|
| 102 | wait = 17; // 0x11 |
---|
| 103 | res = div_soft(op1,op2); |
---|
| 104 | |
---|
| 105 | print(res); |
---|
| 106 | test2 &= (wait == res); |
---|
| 107 | } |
---|
| 108 | { |
---|
| 109 | #ifdef HAVE_LIBC |
---|
| 110 | printf(" * Test_02b\n"); |
---|
| 111 | #else |
---|
| 112 | print(0xABCD002B); |
---|
| 113 | #endif |
---|
| 114 | |
---|
| 115 | op1 = 15431115; // eb75cb |
---|
| 116 | op2 = 9835; // 266b |
---|
| 117 | wait = 1569; // 621 |
---|
| 118 | res = div_soft(op1,op2); |
---|
| 119 | |
---|
| 120 | print(res); |
---|
| 121 | test2 &= (wait == res); |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | return test2; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | //---------------------------------- |
---|
| 128 | // TEST 3 |
---|
| 129 | // multiplication hardware (*) |
---|
| 130 | //---------------------------------- |
---|
| 131 | int test_03 () |
---|
| 132 | { |
---|
| 133 | int op1, op2, wait, res; |
---|
| 134 | #ifdef HAVE_LIBC |
---|
| 135 | printf("Test_03 - mul_hard\n"); |
---|
| 136 | #else |
---|
| 137 | print(0xABCD0003); |
---|
| 138 | #endif |
---|
| 139 | |
---|
| 140 | op1 = 1569; |
---|
| 141 | op2 = 9835; |
---|
| 142 | wait = 15431115; // 0xEB75CB |
---|
| 143 | res = mul_hard(op1,op2); |
---|
| 144 | |
---|
| 145 | print(res); |
---|
| 146 | return (wait == res); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | //---------------------------------- |
---|
| 150 | // TEST 4 |
---|
| 151 | // division hardware (/) |
---|
| 152 | //---------------------------------- |
---|
| 153 | int test_04 () |
---|
| 154 | { |
---|
| 155 | int op1, op2, wait, res; |
---|
| 156 | #ifdef HAVE_LIBC |
---|
| 157 | printf("Test_04 - div_hard\n"); |
---|
| 158 | #else |
---|
| 159 | print(0xABCD0004); |
---|
| 160 | #endif |
---|
| 161 | |
---|
| 162 | op1 = 15431115; |
---|
| 163 | op2 = 9835; |
---|
| 164 | wait = 1569; // 0x621 |
---|
| 165 | res = div_hard(op1,op2); |
---|
| 166 | |
---|
| 167 | print(res); |
---|
| 168 | return (wait == res); |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | //---------------------------------- |
---|
| 173 | // TEST 5 |
---|
| 174 | // modulo |
---|
| 175 | //---------------------------------- |
---|
| 176 | int test_05 () |
---|
| 177 | { |
---|
| 178 | int op1, op2, wait, res; |
---|
| 179 | #ifdef HAVE_LIBC |
---|
| 180 | printf("Test_05 - modulo\n"); |
---|
| 181 | #else |
---|
| 182 | print(0xABCD0005); |
---|
| 183 | #endif |
---|
| 184 | |
---|
| 185 | op1 = 16834; |
---|
| 186 | op2 = 563; |
---|
| 187 | wait = 507; // 0x1fb |
---|
| 188 | res = modulo(op1,op2); |
---|
| 189 | |
---|
| 190 | print(res); |
---|
| 191 | return (wait == res); |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | //---------------------------------- |
---|
| 195 | // TEST 6 |
---|
| 196 | // fibonnacci |
---|
| 197 | //---------------------------------- |
---|
| 198 | int test_06 () |
---|
| 199 | { |
---|
| 200 | int it, test; |
---|
| 201 | int x = PARAM_06; |
---|
| 202 | int x_max = 43; |
---|
| 203 | |
---|
| 204 | int res [x_max+1]; |
---|
| 205 | int wait [x_max+1]; |
---|
| 206 | #ifdef HAVE_LIBC |
---|
| 207 | printf("Test_06 - fibonnacci\n"); |
---|
| 208 | #else |
---|
| 209 | print(0xABCD0006); |
---|
| 210 | #endif |
---|
| 211 | wait [0] = 1; // 1 |
---|
| 212 | wait [1] = 2; // 2 |
---|
| 213 | wait [2] = 3; // 3 |
---|
| 214 | wait [3] = 5; // 5 |
---|
| 215 | wait [4] = 8; // 8 |
---|
| 216 | wait [5] = 13; // d |
---|
| 217 | wait [6] = 21; // 15 |
---|
| 218 | wait [7] = 34; // 22 |
---|
| 219 | wait [8] = 55; // 37 |
---|
| 220 | wait [9] = 89; // 59 |
---|
| 221 | wait [10] = 144; // 90 |
---|
| 222 | wait [11] = 233; // e9 |
---|
| 223 | wait [12] = 377; // 179 |
---|
| 224 | wait [13] = 610; // 262 |
---|
| 225 | wait [14] = 987; // 3db |
---|
| 226 | wait [15] = 1597; // 63d |
---|
| 227 | wait [16] = 2584; // a18 |
---|
| 228 | wait [17] = 4181; // 1055 |
---|
| 229 | wait [18] = 6765; // 1a6d |
---|
| 230 | wait [19] = 10946; // 2ac2 |
---|
| 231 | wait [20] = 17711; // 452f |
---|
| 232 | wait [21] = 28657; // 6ff1 |
---|
| 233 | wait [22] = 46368; // b520 |
---|
| 234 | wait [23] = 75025; // 12511 |
---|
| 235 | wait [24] = 121393; // 1da31 |
---|
| 236 | wait [25] = 196418; // 2ff42 |
---|
| 237 | wait [26] = 317811; // 4d973 |
---|
| 238 | wait [27] = 514229; // 7d8b5 |
---|
| 239 | wait [28] = 832040; // cb228 |
---|
| 240 | wait [29] = 1346269; // 148add |
---|
| 241 | wait [30] = 2178309; // 213d05 |
---|
| 242 | wait [31] = 3524578; // 35c7e2 |
---|
| 243 | wait [32] = 5702887; // 5704e7 |
---|
| 244 | wait [33] = 9227465; // 8cccc9 |
---|
| 245 | wait [34] = 14930352; // e3d1b0 |
---|
| 246 | wait [35] = 24157817; // 1709e79 |
---|
| 247 | wait [36] = 39088169; // 2547029 |
---|
| 248 | wait [37] = 63245986; // 3c50ea2 |
---|
| 249 | wait [38] = 102334155; // 6197ecb |
---|
| 250 | wait [39] = 165580141; // 9de8d6d |
---|
| 251 | wait [40] = 267914296; // ff80c38 |
---|
| 252 | wait [41] = 433494437; // 19d699a5 |
---|
| 253 | wait [42] = 701408733; // 29cea5dd |
---|
| 254 | wait [43] = 1134903170; // 43a53f82 |
---|
| 255 | |
---|
| 256 | for (it = 0; it <= x ; it ++) |
---|
| 257 | { |
---|
| 258 | res [it] = fibonnacci (it); |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | test = 1; |
---|
| 262 | |
---|
| 263 | for (it = 0; it <= x ; it ++) |
---|
| 264 | test &= (res [it] == wait [it]); |
---|
| 265 | |
---|
| 266 | print(test); |
---|
| 267 | return (test); |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | //---------------------------------- |
---|
| 271 | // TEST 7 |
---|
| 272 | // n_premier |
---|
| 273 | // * |
---|
| 274 | //---------------------------------- |
---|
| 275 | int test_07 () |
---|
| 276 | { |
---|
| 277 | unsigned int it, test; |
---|
| 278 | unsigned int x = PARAM_07; |
---|
| 279 | unsigned int x_max = 30; |
---|
| 280 | unsigned int res [x_max+1]; |
---|
| 281 | unsigned int wait [x_max+1]; |
---|
| 282 | #ifdef HAVE_LIBC |
---|
| 283 | printf("Test_07 - n_premier\n"); |
---|
| 284 | #else |
---|
| 285 | print(0xABCD0007); |
---|
| 286 | #endif |
---|
| 287 | |
---|
| 288 | wait [0] = 1; // 1 |
---|
| 289 | wait [1] = 2; // 2 |
---|
| 290 | wait [2] = 3; // 3 |
---|
| 291 | wait [3] = 5; // 5 |
---|
| 292 | wait [4] = 7; // 7 |
---|
| 293 | wait [5] = 11; // b |
---|
| 294 | wait [6] = 13; // d |
---|
| 295 | wait [7] = 17; // 11 |
---|
| 296 | wait [8] = 19; // 13 |
---|
| 297 | wait [9] = 23; // 17 |
---|
| 298 | wait [10] = 29; // 1d |
---|
| 299 | wait [11] = 31; // 1f |
---|
| 300 | wait [12] = 37; // 25 |
---|
| 301 | wait [13] = 41; // 29 |
---|
| 302 | wait [14] = 43; // 2b |
---|
| 303 | wait [15] = 47; // 2f |
---|
| 304 | wait [16] = 53; // 35 |
---|
| 305 | wait [17] = 59; // 3b |
---|
| 306 | wait [18] = 61; // 3d |
---|
| 307 | wait [19] = 67; // 43 |
---|
| 308 | wait [20] = 71; // 47 |
---|
| 309 | wait [21] = 73; // 49 |
---|
| 310 | wait [22] = 79; // 4f |
---|
| 311 | wait [23] = 83; // 53 |
---|
| 312 | wait [24] = 89; // 59 |
---|
| 313 | wait [25] = 97; // 61 |
---|
| 314 | wait [26] = 101; // 65 |
---|
| 315 | wait [27] = 103; // 67 |
---|
| 316 | wait [28] = 107; // 6b |
---|
| 317 | wait [29] = 109; // 6d |
---|
| 318 | wait [30] = 113; // 71 |
---|
| 319 | |
---|
| 320 | for (it = 0; it <= x ; it ++) |
---|
| 321 | { |
---|
| 322 | res [it] = n_premier(it); |
---|
| 323 | print (res [it]); |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | test = 1; |
---|
| 327 | |
---|
| 328 | for (it = 0; it <= x ; it ++) |
---|
| 329 | test &= (res [it] == wait [it]); |
---|
| 330 | |
---|
| 331 | print(test); |
---|
| 332 | return (test); |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | //---------------------------------- |
---|
| 336 | // TEST 8 |
---|
| 337 | // tri_croissant (tableau d'int) |
---|
| 338 | // tri_croissant (tableau de short) |
---|
| 339 | // tri_croissant (tableau de char) |
---|
| 340 | // * |
---|
| 341 | //---------------------------------- |
---|
| 342 | #include <string.h> |
---|
| 343 | #include <stdlib.h> |
---|
| 344 | |
---|
| 345 | int test_08 () |
---|
| 346 | { |
---|
| 347 | int x = PARAM_08; |
---|
| 348 | const int size = x; |
---|
| 349 | const int nb_algo_max = 4; |
---|
| 350 | |
---|
| 351 | int array_ref [size]; |
---|
| 352 | int array [nb_algo_max][size]; |
---|
| 353 | int it; |
---|
| 354 | int nb_algo; |
---|
| 355 | |
---|
| 356 | /* |
---|
| 357 | * PHASE 1 : Initialisation |
---|
| 358 | */ |
---|
| 359 | |
---|
| 360 | // Remplir le tableau |
---|
| 361 | |
---|
| 362 | srand(0); |
---|
| 363 | |
---|
| 364 | for (it = 0; it < size ; it++) |
---|
| 365 | { |
---|
| 366 | array_ref [it] = rand(); |
---|
| 367 | for (nb_algo = 0; nb_algo < nb_algo_max; nb_algo ++) |
---|
| 368 | array[nb_algo][it] = array_ref [it]; |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | { |
---|
| 372 | #ifdef HAVE_LIBC |
---|
| 373 | printf("Test_08 - tri_croissant\n"); |
---|
| 374 | #else |
---|
| 375 | print(0xABCD0008); |
---|
| 376 | #endif |
---|
| 377 | |
---|
| 378 | for (nb_algo = 0; nb_algo < nb_algo_max; nb_algo ++) |
---|
| 379 | { |
---|
| 380 | // for (it = 0; it < size ; it++) |
---|
| 381 | // printf("%d ",array [it]); |
---|
| 382 | // printf("\n"); |
---|
| 383 | |
---|
| 384 | /* |
---|
| 385 | * PHASE 2 : Exécution |
---|
| 386 | */ |
---|
| 387 | #ifdef HAVE_LIBC |
---|
| 388 | printf(" * tri_croissant - algo %d\n",nb_algo); |
---|
| 389 | #endif |
---|
| 390 | print(0xABCD08a0 | nb_algo); |
---|
| 391 | array_tri_croissant (array[nb_algo] ,size,nb_algo); |
---|
| 392 | print(0xABCD08b0 | nb_algo); |
---|
| 393 | |
---|
| 394 | // for (it = 0; it < size ; it++) |
---|
| 395 | // printf("%d ",array [it]); |
---|
| 396 | // printf("\n"); |
---|
| 397 | } |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | /* |
---|
| 401 | * PHASE 3 : Vérification des résultats |
---|
| 402 | */ |
---|
| 403 | |
---|
| 404 | // Vérifier le résultat : compte le nombre de case identique par algoritme |
---|
| 405 | for (it = 0; it < size ; it++) |
---|
| 406 | { |
---|
| 407 | int val = array[0][it]; |
---|
| 408 | |
---|
| 409 | for (nb_algo = 1; nb_algo < nb_algo_max; nb_algo ++) |
---|
| 410 | if (val != array[nb_algo][it]) |
---|
| 411 | return 0; |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | return (1); |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | //---------------------------------- |
---|
| 418 | // TEST 9 - hanoi |
---|
| 419 | // |
---|
| 420 | //---------------------------------- |
---|
| 421 | int test_09 () |
---|
| 422 | { |
---|
| 423 | unsigned int it, test; |
---|
| 424 | unsigned int x = PARAM_09; |
---|
| 425 | unsigned int x_max = 12; |
---|
| 426 | |
---|
| 427 | unsigned int res [x_max+1]; |
---|
| 428 | unsigned int wait [x_max+1]; |
---|
| 429 | #ifdef HAVE_LIBC |
---|
| 430 | printf("Test_09 - hanoi\n"); |
---|
| 431 | #else |
---|
| 432 | print(0xABCD0009); |
---|
| 433 | #endif |
---|
| 434 | |
---|
| 435 | wait [1] = 1; // 1 |
---|
| 436 | wait [2] = 3; // 3 |
---|
| 437 | wait [3] = 7; // 7 |
---|
| 438 | wait [4] = 15; // f |
---|
| 439 | wait [5] = 31; // 1f |
---|
| 440 | wait [6] = 63; // 3f |
---|
| 441 | wait [7] = 127; // 7f |
---|
| 442 | wait [8] = 255; // ff |
---|
| 443 | wait [9] = 511; // 1ff |
---|
| 444 | wait [10] = 1023; // 3ff |
---|
| 445 | wait [11] = 2047; // 7ff |
---|
| 446 | wait [12] = 4095; // fff |
---|
| 447 | |
---|
| 448 | for (it = 1; it <= x ; it ++) |
---|
| 449 | { |
---|
| 450 | res [it] = hanoi (it); |
---|
| 451 | |
---|
| 452 | print(res [it]); |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | test = 1; |
---|
| 456 | |
---|
| 457 | for (it = 1; it <= x ; it ++) |
---|
| 458 | test &= (res [it] == wait [it]); |
---|
| 459 | |
---|
| 460 | print(test); |
---|
| 461 | return (test); |
---|
| 462 | |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | //---------------------------------- |
---|
| 466 | // TEST 10 |
---|
| 467 | // multiplication de matrice |
---|
| 468 | // * |
---|
| 469 | //---------------------------------- |
---|
| 470 | int test_10 () |
---|
| 471 | { |
---|
| 472 | int op1, op2, res; |
---|
| 473 | int x = PARAM_10; |
---|
| 474 | #ifdef HAVE_LIBC |
---|
| 475 | printf("Test_10 - multiplication de matrice\n"); |
---|
| 476 | #else |
---|
| 477 | print(0xABCD0010); |
---|
| 478 | #endif |
---|
| 479 | |
---|
| 480 | op1 = x; |
---|
| 481 | op2 = 1; |
---|
| 482 | res = mm(op1,op2); |
---|
| 483 | |
---|
| 484 | print(res); |
---|
| 485 | return (res); |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | //---------------------------------- |
---|
| 489 | // TEST 11 |
---|
| 490 | // factoriel_recursif |
---|
| 491 | //---------------------------------- |
---|
| 492 | int test_11 () |
---|
| 493 | { |
---|
| 494 | unsigned int it, test; |
---|
| 495 | unsigned int x = PARAM_11; |
---|
| 496 | unsigned int x_max = 12; |
---|
| 497 | |
---|
| 498 | unsigned int res [x_max+1]; |
---|
| 499 | unsigned int wait [x_max+1]; |
---|
| 500 | #ifdef HAVE_LIBC |
---|
| 501 | printf("Test_11 - factoriel recursif\n"); |
---|
| 502 | #else |
---|
| 503 | print(0xABCD0011); |
---|
| 504 | #endif |
---|
| 505 | |
---|
| 506 | wait[0] = 1; // 1 |
---|
| 507 | wait[1] = 1; // 1 |
---|
| 508 | wait[2] = 2; // 2 |
---|
| 509 | wait[3] = 6; // 6 |
---|
| 510 | wait[4] = 24; // 18 |
---|
| 511 | wait[5] = 120; // 78 |
---|
| 512 | wait[6] = 720; // 2d0 |
---|
| 513 | wait[7] = 5040; // 13b0 |
---|
| 514 | wait[8] = 40320; // 9d80 |
---|
| 515 | wait[9] = 362880; // 58980 |
---|
| 516 | wait[10] = 3628800; // 375f00 |
---|
| 517 | wait[11] = 39916800; // 2611500 |
---|
| 518 | wait[12] = 479001600; // 1c8cfc00 |
---|
| 519 | |
---|
| 520 | for (it = 0; it <= x ; it ++) |
---|
| 521 | res [it] = fact_recursif (it); |
---|
| 522 | |
---|
| 523 | test = 1; |
---|
| 524 | |
---|
| 525 | for (it = 0; it <= x ; it ++) |
---|
| 526 | test &= (res [it] == wait [it]); |
---|
| 527 | |
---|
| 528 | print(test); |
---|
| 529 | return (test); |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | //---------------------------------- |
---|
| 533 | // TEST 12 |
---|
| 534 | // factoriel_iteratif |
---|
| 535 | //---------------------------------- |
---|
| 536 | int test_12 () |
---|
| 537 | { |
---|
| 538 | unsigned int it, test; |
---|
| 539 | |
---|
| 540 | unsigned int x = PARAM_12; |
---|
| 541 | unsigned int x_max = 12; |
---|
| 542 | |
---|
| 543 | unsigned int res [x_max+1]; |
---|
| 544 | unsigned int wait [x_max+1]; |
---|
| 545 | #ifdef HAVE_LIBC |
---|
| 546 | printf("Test_12 - factoriel_iteratif\n"); |
---|
| 547 | #else |
---|
| 548 | print(0xABCD0012); |
---|
| 549 | #endif |
---|
| 550 | |
---|
| 551 | wait[0] = 1; // 1 |
---|
| 552 | wait[1] = 1; // 1 |
---|
| 553 | wait[2] = 2; // 2 |
---|
| 554 | wait[3] = 6; // 6 |
---|
| 555 | wait[4] = 24; // 18 |
---|
| 556 | wait[5] = 120; // 78 |
---|
| 557 | wait[6] = 720; // 2d0 |
---|
| 558 | wait[7] = 5040; // 13b0 |
---|
| 559 | wait[8] = 40320; // 9d80 |
---|
| 560 | wait[9] = 362880; // 58980 |
---|
| 561 | wait[10] = 3628800; // 375f00 |
---|
| 562 | wait[11] = 39916800; // 2611500 |
---|
| 563 | wait[12] = 479001600; // 1c8cfc00 |
---|
| 564 | |
---|
| 565 | for (it = 0; it <= x ; it ++) |
---|
| 566 | res [it] = fact_iteratif (it); |
---|
| 567 | |
---|
| 568 | test = 1; |
---|
| 569 | |
---|
| 570 | for (it = 0; it <= x ; it ++) |
---|
| 571 | test &= (res [it] == wait [it]); |
---|
| 572 | |
---|
| 573 | print(test); |
---|
| 574 | return (test); |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | //---------------------------------- |
---|
| 578 | // TEST 13 |
---|
| 579 | // parite |
---|
| 580 | //---------------------------------- |
---|
| 581 | int test_13 () |
---|
| 582 | { |
---|
| 583 | unsigned int it; |
---|
| 584 | unsigned int x = PARAM_13; |
---|
| 585 | unsigned int pair,test; |
---|
| 586 | |
---|
| 587 | #define TEST(a,b) ( ( (a) ^ (b) ) == 0)?1:0 |
---|
| 588 | #ifdef HAVE_LIBC |
---|
| 589 | printf("Test_13 - parite\n"); |
---|
| 590 | #else |
---|
| 591 | print(0xABCD0013); |
---|
| 592 | #endif |
---|
| 593 | |
---|
| 594 | test = 1; |
---|
| 595 | |
---|
| 596 | pair = 1; |
---|
| 597 | srand(0); |
---|
| 598 | for (it = 0; (it < x) && (test == 1); it ++) |
---|
| 599 | { |
---|
| 600 | unsigned int val = (unsigned int) rand(); |
---|
| 601 | unsigned int val1 = parite1(val,pair); |
---|
| 602 | unsigned int val2 = parite2(val,pair); |
---|
| 603 | test &= TEST(val1,val2); // Test if 2 implementation produced the same result |
---|
| 604 | } |
---|
| 605 | print(test); |
---|
| 606 | |
---|
| 607 | pair ^= 1; |
---|
| 608 | for (it = 0; (it < x) && (test == 1); it ++) |
---|
| 609 | { |
---|
| 610 | unsigned int val = (unsigned int) rand(); |
---|
| 611 | unsigned int val1 = parite1(val,pair); |
---|
| 612 | unsigned int val2 = parite2(val,pair); |
---|
| 613 | test &= TEST(val1,val2); // Test if 2 implementation produced the same result |
---|
| 614 | } |
---|
| 615 | print(test); |
---|
| 616 | return (test); |
---|
| 617 | } |
---|