Oh nice System.SysUtils.TCardinalHelper.Parse:
class function TCardinalHelper.Parse(const S: string): Cardinal;
begin
Result := StrToInt(S);
end;
Which means you get this nice EConvertError with message ''4294967295' is not a valid integer value'. with this simple test (which doesn’t even reach the Assert):
uses
System.SysUtils;
procedure Cardinal_Parse_High_Cardinal_Succeeds();
var
Expected: Cardinal;
Value: string;
Actual: Cardinal;
begin
Expected := High(Cardinal);
Value := Expected.ToString();
Actual := Cardinal.Parse(Value);
Assert(Expected = Actual);
end;
So I write some unit tests (see below) of which helpers for these types fail in one way or the other:
- Cardinal
- NativeUInt
- Single
- Double
- Extended
These work for the boundary cases:
- SmallInt
- ShortInt
- Integer
- Int64
- NativeInt
- Byte
- Word
- UInt64
- Boolean
- ByteBool
- WordBool
- LongBool
–jeroen
via: Oh nice, in System.SysUtils: “` class function TCardinalHelper.Parse(const…
Read the rest of this entry »