-
+ C4B3EE6BA2CA9F80D36D2E5C04B75A1ECE625A24A4782A76521E07DE7DD8803E3BCDB0380C9EA723B4A5801856298A47CF691088C05B903E6CFFA2A53B2EDD38
eucrypt/crc32/tests/test_crc32_edge.adb
(0 . 0)(1 . 67)
465 ------------------------------------------------------------------------------
466 ------------------------------------------------------------------------------
467 -- This file is part of 'CRC32' --
468 -- --
469 -- You do not have, nor can you ever acquire the right to use, copy or --
470 -- distribute this software ; Should you use this software for any purpose, --
471 -- or copy and distribute it to anyone or in any manner, you are breaking --
472 -- the laws of whatever soi-disant jurisdiction, and you promise to --
473 -- continue doing so for the indefinite future. In any case, please --
474 -- always : read and understand any software ; verify any PGP signatures --
475 -- that you use - for any purpose. --
476 -- --
477 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
478 ------------------------------------------------------------------------------
479 ------------------------------------------------------------------------------
480
481 -- Edge testing for the CRC32 implementation
482 -- S.MG, 2018
483
484 with Ada.Text_IO; use Ada.Text_IO;
485 with Interfaces; use Interfaces;
486 with CRC32;
487
488
489 procedure Test_CRC32_Edge is
490 Empty : constant Character := Character'Val(0);
491 Full : constant Character := Character'Val(16#FF#);
492
493 S0 : String := Empty & Empty & Empty & Empty;
494 S255 : String := Full & Full & Full & Full;
495
496 S0F : String := Character'Val(16#0F#) & Character'Val(16#0F#);
497 SF0 : String := Character'Val(16#F0#) & Character'Val(16#F0#);
498
499 C : CRC32.CRC32 := 0;
500 begin
501 -- First some tests, independent of the bit order
502 C := CRC32.CRC(S0);
503 pragma Assert(C = 558161692,
504 "Test_CRC32_Edge - assert 1 - C is " & CRC32.CRC32'Image(C)
505 & " should be 558161692");
506 C := CRC32.CRC(S255);
507 pragma Assert(C = 16#FFFFFFFF#,
508 "Test_CRC32_Edge - assert 2 - C is " & CRC32.CRC32'Image(C)
509 & " should be 4294967295");
510 C := CRC32.CRC(S0(1 .. 1));
511 pragma Assert(C = 3523407757,
512 "Test_CRC32_Edge - assert 3 - C is " & CRC32.CRC32'Image(C)
513 & " should be 3523407757");
514 C := CRC32.CRC(S0(1 .. 2));
515 pragma Assert(C = 1104745215,
516 "Test_CRC32_Edge - assert 4 - C is " & CRC32.CRC32'Image(C)
517 & " should be 1104745215");
518
519 -- The bitorder in CRC32 is reversed, check if implemented correctly
520 C := CRC32.CRC(S0F);
521 pragma Assert(C = 1459491745,
522 "Test_CRC32_Edge - assert 5 - C is " & CRC32.CRC32'Image(C)
523 & " should be 1459491745");
524
525 C := CRC32.CRC(SF0);
526 pragma Assert(C = 3906470238,
527 "Test_CRC32_Edge - assert 6 - C is " & CRC32.CRC32'Image(C)
528 & " should be 3906470238");
529
530
531 end Test_CRC32_Edge;