File tree 2 files changed +16
-1
lines changed 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ function TSqids.ToNumber(AId: string; AAlphabet: string): TNumber;
185
185
L := Length(AAlphabet);
186
186
187
187
for C in AId do
188
- Result := Result * L + TNumber(Pos(C, AAlphabet)) - 1 ;
188
+ Result := Result * L + ( TNumber(Pos(C, AAlphabet)) - 1 ) ;
189
189
end ;
190
190
191
191
function TSqids.IsBlocked (AId: string): Boolean;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ TTestEncoding = class(TTestCase)
22
22
procedure IdWithInvalidCharacter ;
23
23
// out-of-range test not implemented:
24
24
// compiler enforces that all numbers are within the range of a TNumber
25
+ procedure ExtremeValue ;
25
26
end ;
26
27
27
28
implementation
@@ -180,6 +181,20 @@ procedure TTestEncoding.EmptyString;
180
181
end ;
181
182
end ;
182
183
184
+ procedure TTestEncoding.ExtremeValue ;
185
+ const
186
+ Number: TNumber = $FFFFFFFFFFFFFFFF;
187
+ Id = ' eIkvoXH40Lmd' ; // from a previous EncodeSingle
188
+ begin
189
+ with TSqids.Create do
190
+ try
191
+ CheckEquals(EncodeSingle(Number), Id);
192
+ CheckTrue(DecodeSingle(id)=Number);
193
+ finally
194
+ Free;
195
+ end ;
196
+ end ;
197
+
183
198
procedure TTestEncoding.IdWithInvalidCharacter ;
184
199
begin
185
200
with TSqids.Create do
You can’t perform that action at this time.
0 commit comments