1
0
mirror of synced 2024-09-18 17:26:08 +00:00
x2utils/UnitTests/Units/BitsTest.pas
Mark van Renswoude 6429b349c3 Added: unit tests for hashes
Added: Clear method
Fixed: bug in key storage and comparison
2005-07-01 11:43:59 +00:00

93 lines
1.6 KiB
ObjectPascal

unit BitsTest;
interface
uses
TestFramework;
type
TBitsTest = class(TTestCase)
published
procedure testGet();
procedure testSet();
procedure testCombine();
procedure testBitsToString();
procedure testStringToBits();
end;
implementation
uses
X2UtBits;
const
Bits = [bit1, bit2, bit4, bit7];
BitsValue = 150;
BitsString = '10010110';
{ TBitsTest }
procedure TBitsTest.testGet;
var
bValue: Byte;
eBits: T8Bits absolute bValue;
begin
bValue := BitsValue;
Check(eBits = Bits, 'Bits do not match the value!');
end;
procedure TBitsTest.testSet;
var
bValue: Byte;
eBits: T8Bits absolute bValue;
begin
eBits := Bits;
Check(bValue = BitsValue, 'Value does not match the bits!');
end;
procedure TBitsTest.testCombine;
var
eBits1: T8Bits;
eBits2: T8Bits;
bValue: Byte absolute eBits1;
begin
eBits1 := [bit1, bit7];
eBits2 := [bit2, bit4];
eBits1 := eBits1 + eBits2;
Check(bValue = BitsValue, 'Value does not match the bits!');
end;
procedure TBitsTest.testBitsToString;
var
eBits: T8Bits;
sValue: String;
begin
eBits := Bits;
sValue := BitsToString(eBits, bs8);
Check(sValue = BitsString, 'Bits do not match the string!');
end;
procedure TBitsTest.testStringToBits;
var
eBits: T8Bits;
sValue: String;
begin
sValue := BitsString;
eBits := StringToBits(sValue);
Check(eBits = Bits, 'String does not match the bits!');
end;
initialization
RegisterTest('Bits', TBitsTest.Suite);
end.