-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTestSizeEncoding.dpr
61 lines (51 loc) · 1.57 KB
/
TestSizeEncoding.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
program TestSizeEncoding;
{$APPTYPE CONSOLE}
{$R *.res}
uses
SysUtils,
Classes,
Types,
AVXBase64_x64 in 'AVXBase64_x64.pas',
AVXBase64_x86 in 'AVXBase64_x86.pas',
FastBase64 in 'FastBase64.pas',
FastBase64Const in 'FastBase64Const.pas';
var mem : TMemoryStream;
dest : RawByteString;
memDecode : TByteDynArray;
i, j : Integer;
pMem : PByteArray;
doPad : boolean;
begin
try
{ TODO -oUser -cConsole Main : Code hier einfügen }
for doPad in [false, true] do
begin
for i := 7 to 127 do
begin
mem := TMemoryStream.Create;
try
mem.SetSize(i);
pMem := mem.Memory;
for j := 0 to i - 1 do
begin
pMem^[j] := Byte(random(255));
end;
dest := Base64Encode(mem.Memory, mem.Size, doPad);
if not Base64Decode(dest, memDecode, doPad ) then
raise Exception.Create('Failed to Decode');
if Length(memDecode) <> mem.Size then
raise Exception.Create('Bad Size');
if not CompareMem(mem.Memory, @memDecode[0], Length(memDecode)) then
raise Exception.Create('Bad encode/decode');
finally
mem.Free;
end;
end;
end;
writeln('Test passed');
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
readln;
end.