raw
eucrypt_crc32_div...    1 ------------------------------------------------------------------------------
eucrypt_crc32_div... 2 ------------------------------------------------------------------------------
eucrypt_crc32_div... 3 -- This file is part of 'CRC32' --
eucrypt_crc32_div... 4 -- --
eucrypt_crc32_div... 5 -- You do not have, nor can you ever acquire the right to use, copy or --
eucrypt_crc32_div... 6 -- distribute this software ; Should you use this software for any purpose, --
eucrypt_crc32_div... 7 -- or copy and distribute it to anyone or in any manner, you are breaking --
eucrypt_crc32_div... 8 -- the laws of whatever soi-disant jurisdiction, and you promise to --
eucrypt_crc32_div... 9 -- continue doing so for the indefinite future. In any case, please --
eucrypt_crc32_div... 10 -- always : read and understand any software ; verify any PGP signatures --
eucrypt_crc32_div... 11 -- that you use - for any purpose. --
eucrypt_crc32_div... 12 -- --
eucrypt_crc32_div... 13 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
eucrypt_crc32_div... 14 ------------------------------------------------------------------------------
eucrypt_crc32_div... 15 ------------------------------------------------------------------------------
eucrypt_crc32_div... 16
eucrypt_crc32_div... 17 -- Edge testing for the CRC32 implementation
eucrypt_crc32_div... 18 -- S.MG, 2018
eucrypt_crc32_div... 19
eucrypt_crc32_div... 20 with Ada.Text_IO; use Ada.Text_IO;
eucrypt_crc32_div... 21 with Interfaces; use Interfaces;
eucrypt_crc32_div... 22 with CRC32;
eucrypt_crc32_div... 23
eucrypt_crc32_div... 24
eucrypt_crc32_div... 25 procedure Test_CRC32_Edge is
eucrypt_crc32_div... 26 Empty : constant Character := Character'Val(0);
eucrypt_crc32_div... 27 Full : constant Character := Character'Val(16#FF#);
eucrypt_crc32_div... 28
eucrypt_crc32_div... 29 S0 : String := Empty & Empty & Empty & Empty;
eucrypt_crc32_div... 30 S255 : String := Full & Full & Full & Full;
eucrypt_crc32_div... 31
eucrypt_crc32_div... 32 S0F : String := Character'Val(16#0F#) & Character'Val(16#0F#);
eucrypt_crc32_div... 33 SF0 : String := Character'Val(16#F0#) & Character'Val(16#F0#);
eucrypt_crc32_div... 34
eucrypt_crc32_div... 35 C : CRC32.CRC32 := 0;
eucrypt_crc32_div... 36 begin
eucrypt_crc32_div... 37 -- First some tests, independent of the bit order
eucrypt_crc32_div... 38 C := CRC32.CRC(S0);
eucrypt_crc32_div... 39 pragma Assert(C = 558161692,
eucrypt_crc32_div... 40 "Test_CRC32_Edge - assert 1 - C is " & CRC32.CRC32'Image(C)
eucrypt_crc32_div... 41 & " should be 558161692");
eucrypt_crc32_div... 42 C := CRC32.CRC(S255);
eucrypt_crc32_div... 43 pragma Assert(C = 16#FFFFFFFF#,
eucrypt_crc32_div... 44 "Test_CRC32_Edge - assert 2 - C is " & CRC32.CRC32'Image(C)
eucrypt_crc32_div... 45 & " should be 4294967295");
eucrypt_crc32_div... 46 C := CRC32.CRC(S0(1 .. 1));
eucrypt_crc32_div... 47 pragma Assert(C = 3523407757,
eucrypt_crc32_div... 48 "Test_CRC32_Edge - assert 3 - C is " & CRC32.CRC32'Image(C)
eucrypt_crc32_div... 49 & " should be 3523407757");
eucrypt_crc32_div... 50 C := CRC32.CRC(S0(1 .. 2));
eucrypt_crc32_div... 51 pragma Assert(C = 1104745215,
eucrypt_crc32_div... 52 "Test_CRC32_Edge - assert 4 - C is " & CRC32.CRC32'Image(C)
eucrypt_crc32_div... 53 & " should be 1104745215");
eucrypt_crc32_div... 54
eucrypt_crc32_div... 55 -- The bitorder in CRC32 is reversed, check if implemented correctly
eucrypt_crc32_div... 56 C := CRC32.CRC(S0F);
eucrypt_crc32_div... 57 pragma Assert(C = 1459491745,
eucrypt_crc32_div... 58 "Test_CRC32_Edge - assert 5 - C is " & CRC32.CRC32'Image(C)
eucrypt_crc32_div... 59 & " should be 1459491745");
eucrypt_crc32_div... 60
eucrypt_crc32_div... 61 C := CRC32.CRC(SF0);
eucrypt_crc32_div... 62 pragma Assert(C = 3906470238,
eucrypt_crc32_div... 63 "Test_CRC32_Edge - assert 6 - C is " & CRC32.CRC32'Image(C)
eucrypt_crc32_div... 64 & " should be 3906470238");
eucrypt_crc32_div... 65
eucrypt_crc32_div... 66
eucrypt_crc32_div... 67 end Test_CRC32_Edge;