Skip to content

Commit

Permalink
Add fpc test for encoding/decoding $FFFFFFFFFFFFFFFF
Browse files Browse the repository at this point in the history
  • Loading branch information
dokkie8844 committed May 24, 2024
1 parent 18f3484 commit a3efb87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 15 additions & 0 deletions tests/fpc/encoding.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ TTestEncoding = class(TTestCase)
procedure IdWithInvalidCharacter;
// out-of-range test not implemented:
// compiler enforces that all numbers are within the range of a TNumber
procedure ExtremeValue;
end;

implementation
Expand Down Expand Up @@ -189,6 +190,20 @@ procedure TTestEncoding.IdWithInvalidCharacter;
end;
end;

procedure TTestEncoding.ExtremeValue;
const
Number: TNumber = $FFFFFFFFFFFFFFFF;
Id = 'eIkvoXH40Lmd'; // from a previous EncodeSingle
begin
with TSqids.Create do
try
AssertEquals(EncodeSingle(Number), Id);
AssertTrue(DecodeSingle(Id) = Number);
finally
Free;
end;
end;

initialization
RegisterTest(TTestEncoding);

Expand Down
5 changes: 2 additions & 3 deletions tests/fpc/testsqids.lpi
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<MainUnitHasScaledStatement Value="False"/>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="testsqids"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
Expand All @@ -24,7 +24,6 @@
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="1">
<Item1>
Expand Down

0 comments on commit a3efb87

Please sign in to comment.