------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'CRC32' -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- -- -- -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Edge testing for the CRC32 implementation -- S.MG, 2018 with Ada.Text_IO; use Ada.Text_IO; with Interfaces; use Interfaces; with CRC32; procedure Test_CRC32_Edge is Empty : constant Character := Character'Val(0); Full : constant Character := Character'Val(16#FF#); S0 : String := Empty & Empty & Empty & Empty; S255 : String := Full & Full & Full & Full; S0F : String := Character'Val(16#0F#) & Character'Val(16#0F#); SF0 : String := Character'Val(16#F0#) & Character'Val(16#F0#); C : CRC32.CRC32 := 0; begin -- First some tests, independent of the bit order C := CRC32.CRC(S0); pragma Assert(C = 558161692, "Test_CRC32_Edge - assert 1 - C is " & CRC32.CRC32'Image(C) & " should be 558161692"); C := CRC32.CRC(S255); pragma Assert(C = 16#FFFFFFFF#, "Test_CRC32_Edge - assert 2 - C is " & CRC32.CRC32'Image(C) & " should be 4294967295"); C := CRC32.CRC(S0(1 .. 1)); pragma Assert(C = 3523407757, "Test_CRC32_Edge - assert 3 - C is " & CRC32.CRC32'Image(C) & " should be 3523407757"); C := CRC32.CRC(S0(1 .. 2)); pragma Assert(C = 1104745215, "Test_CRC32_Edge - assert 4 - C is " & CRC32.CRC32'Image(C) & " should be 1104745215"); -- The bitorder in CRC32 is reversed, check if implemented correctly C := CRC32.CRC(S0F); pragma Assert(C = 1459491745, "Test_CRC32_Edge - assert 5 - C is " & CRC32.CRC32'Image(C) & " should be 1459491745"); C := CRC32.CRC(SF0); pragma Assert(C = 3906470238, "Test_CRC32_Edge - assert 6 - C is " & CRC32.CRC32'Image(C) & " should be 3906470238"); end Test_CRC32_Edge;