?? test.pas
字號:
unit test;
interface
uses
Windows, SysUtils;
const
//Integer consts testing
cInt1 = -$ffffffffffffffff;
cInt2 = -$fffffffffffffffe;
cInt3 = -$8000000000000001;
//cInt4 = -$8000000000000000; //Overflow in compile time in D6
cInt4 = -$7fffffffffffffff - 1;
cInt5 = -$7fffffffffffffff;
cInt6 = -$7ffffffffffffffe;
cInt7 = -$100000001;
cInt8 = -$100000000;
//cInt9 = -$ffffffff; //Overflow in compile time in D7
//cInt10 = -$fffffffe; //Overflow in compile time in D7
//cInt11 = -$80000001; //Overflow in compile time in D7
//cInt12 = -$80000000; //Overflow in compile time in D7
cInt13 = -$7fffffff;
cInt14 = -$7ffffffe;
cInt16 = -$10001;
cInt17 = -$10000;
cInt18 = -$ffff;
cInt19 = -$fffe;
cInt20 = -$8001;
cInt21 = -$8000;
cInt22 = -$7fff;
cInt23 = -$7ffe;
cInt24 = -$101;
cInt25 = -$100;
cInt26 = -$ff;
cInt27 = -$fe;
cInt28 = -$81;
cInt29 = -$80;
cInt30 = -$7f;
cInt31 = -$7e;
cInt32 = -$1;
cInt33 = -1;
cInt34 = 0;
cInt35 = 1;
cInt36 = $7e;
cInt37 = $7f;
cInt38 = $80;
cInt39 = $81;
cInt41 = $fe;
cInt42 = $ff;
cInt43 = $100;
cInt44 = $7ffe;
cInt45 = $7fff;
cInt46 = $8000;
cInt47 = $8001;
cInt48 = $fffe;
cInt49 = $ffff;
cInt50 = $10000;
cInt51 = $10001;
cInt52 = $7ffffffe;
cInt53 = $7fffffff;
cInt54 = $80000000;
cInt55 = $80000001;
cInt56 = $fffffffe;
cInt57 = $ffffffff;
cInt58 = $100000000;
cInt59 = $100000001;
cInt60 = $7ffffffffffffffe;
cInt61 = $7fffffffffffffff;
cInt62 = $8000000000000000;
cInt63 = $8000000000000001;
cInt64 = $fffffffffffffffe;
cInt65 = $ffffffffffffffff;
//Char consts testing
cC1 = 't';
cC2 = '''';
cC3 = #13;
cC4 = #255;
cC5 = Char(2);
cC6 = Char(6);
cByte = Byte(127);
cShortint = Shortint(-100);
cWord = Word(100);
cSmallint = Smallint(-128);
cInteger = Integer(-1000);
cCardinal = Cardinal(10000);
cInt64_ = Int64(-10000);
cWideChar = WideChar('w');
cSet1 = [1,2,3];
cSet2 = ['a'..'z'];
//String consts testing
cStr1 = 'Hi, how are you? My Email is: soarowl@yeah.net. Good luck to you!';
cStr2 = 'I''m Nengwen Zhuo. My homepages are: http://soarowl.uhome.net, http://soarowl.0catch.com, http://www.websamba.com/soarowl';
cStr3 = #13#10;
cStr4 = '我是卓能文,來自中國大陸';
cStr5 = #13#10'Hello'#13#10'every one'#13#10'來自卓能文的問候';
CWideStr = WideString('This is WideString const');
//Float consts testing
cFloat1 = -123456789.0;
cFloat2 = -1.23456789;
cFloat3 = -1.23456789e-1000;
cFloat4 = -1.23456789e-100;
cFloat5 = -1.23456789e-10;
cFloat6 = -1.23456789e-0;
cFloat7 = -1.23456789e0;
cFloat8 = -1.23456789e10;
cFloat9 = -1.23456789e100;
cFloat10 = -1.23456789e1000;
cFloat11 = 1.23456789e-1000;
cFloat12 = 1.23456789e-100;
cFloat13 = 1.23456789e-10;
cFloat14 = 1.23456789e-0;
cFloat15 = 1.23456789e0;
cFloat16 = 1.23456789e10;
cFloat17 = 1.23456789e100;
cFloat18 = 1.23456789e1000;
cFloat19 = 123456789.0;
cFloat20 = pi;
//Boolean
cBool = true;
//pointer
cPointer = nil;
//Variable consts testing
vcByte1: Byte = 0;
vcByte2: Byte = 127;
vcByte3: Byte = 128;
vcByte4: Byte = 255;
vcShortint1: Shortint = -128;
vcShortint2: Shortint = 0;
vcShortint3: Shortint = 127;
vcWord1: Word = 0;
vcWord2: Word = 32767;
vcWord3: Word = 32768;
vcWord4: Word = 65535;
vcSmallint1: Smallint = -32768;
vcSmallint2: Smallint = -16384;
vcSmallint3: Smallint = 16384;
vcSmallint4: Smallint = -32767;
vcInteger1: Integer = -MaxInt - 1;
vcInteger2: Integer = MaxInt;
vcCardinal1: Cardinal = 0;
vcCardinal2: Cardinal = $ffffffff;
vcInt641: Int64 = -$7fffffffffffffff - 1;
vcInt642: Int64 = $7fffffffffffffff;
vcComp1: Comp = $8000000000000001;
vcComp2: Comp = $7fffffffffffffff;
vcC1: Char = 't';
vcC2: Char = #0;
vcC3: Char = '''';
vcWideC1: WideChar = 't';
vcWideC2: WideChar = #0;
vcWideC3: WideChar = '''';
vcStr: String = 'Test string'''#0'abc';
vcAnsiStr: AnsiString = 'Test AnsiString'''#0'abc';
vcWideStr: WideString = 'Test WideString'''#0'abc';
vcShortStr1: ShortString = 'Test ShortString'''#0'abc';
vcShortStr2: String[50] = 'Test String[50]'''#0'abc';
//!!! You can declare PChar likes following, but the result will be 'Test PChar'''
vcPChar: PChar = 'Test PChar'''#0'abc';
//!!! The result will be 'Test PAnsiChar'''
vcPAnsiChar: PAnsiChar = 'Test PAnsiChar'''#0'abc';
//!!! The result will be 'Test PWideChar'''
vcPWideChar: PWideChar = 'Test PWideChar'''#0'abc';
vcCharRange: 'a'..'z' = 'x';
vcPChar2Char1: PChar = @vcCharRange;
vcPChar2Char2: PChar = @vcPChar;
//type imports const testing
type
MyString = String;
MyTypeString = type String;
MyTypeExtended = type Extended;
const
vcMyStr: MyString = 'This is string type redclaration test';
vcMyTypeStr: MyTypeString = 'This is string type redclaration test with "type" keyword';
vcMyExt: MyTypeExtended = 123456;
//array const testing
vcBoolStrs1: array [Boolean] of String = ('false1','true1');
vcBoolStrs2: array [false..true] of String = ('false2','true2');
vcBoolStrs3: array [0..1] of String = ('false3','true3');
vcStrs4: array[0..2,2..4] of String =
(
('test1','test2','test3'),
('test4','test5','test6'),
('test7','','test9')
);
vcMyStrs: array [1..4] of MyString = ('str1','','str3','str4');
vcMyTypeStrs: array [1..4] of MyTypeString = ('type str1','','type str3','type str4');
vcWideStrs: array[1..4] of WideString = ('WideStr1','','WideStr3','WideStr4');
vcPChars: array[0..2] of PChar = ('PChar1','','PChar3');
vcPWideChars: array[0..2] of PWideChar = ('PWideChar1','','PWideChar3');
vcIntArray1: array[-5..5] of Integer = (1,2,3,4,5,6,7,8,9,10,11);
vcIntArray2: array[1..3,4..6] of Integer =
(
(1,2,3),
(4,5,6),
(7,8,9)
);
type
TDateRec = record
Year: Integer;
Month: (Jan, Feb, Mar, Apr, May, Jun,
Jul, Aug, Sep, Oct, Nov, Dec);
Day: 1..31;
end;
TEmployee = record
FirstName, LastName: string[40];
BirthDate: TDateTime;
case Salaried: Boolean of
True: (AnnualSalary: Currency);
False: (HourlyWage: Currency);
end;
TPerson = record
FirstName, LastName: string[40];
BirthDate: TDateTime;
case Citizen: Boolean of
True: (Birthplace: string[40]);
False: (Country: string[20];
EntryPort: string[20];
EntryDate, ExitDate: TDateTime);
end;
TShapeList = (Rectangle, Triangle, Circle, Ellipse, Other);
TFigure = record
case TShapeList of
Rectangle: (Height, Width: Real);
Triangle: (Side1, Side2, Angle: Real);
Circle: (Radius: Real);
Ellipse, Other: ();
end;
TMyRecord1 = record
I1: Integer;
I2: String;
I3: Char;
I4: Extended;
I5: PChar;
I6: ShortString;
I7: PWideChar;
I8: WideString;
end;
TMyRecord2 = packed record
I1: Integer;
I2: String;
I3: Char;
I4: Extended;
I5: PChar;
I6: ShortString;
I7: PWideChar;
I8: WideString;
end;
const
//record testing
vcRec1: TMyRecord1 = (I1:1; I2:'test'; I3:'C'; I4:pi; I5:'abc';I6: 'xyz'; I7:'123'; I8:'WideString');
vcRec2: TMyRecord2 = (I1:1; I2:'test'; I3:'C'; I4:pi; I5:'abc';I6: 'xyz'; I7:'123'; I8:'WideString');
//Refence Variant record testing
vcRec3: TVarRec = (VInteger: $12345678; VType: vtInteger);
//vcRecArray: packed array[0..1] of TMyRecord1 =
vcRecArray: array[0..1] of TMyRecord2 =
(
(I1:1; I2:'test1'; I3:'C'; I4:pi; I5:'abc1';I6: 'xyz1'; I7:'123'; I8:'WideString1'),
(I1:2; I2:'test2'; I3:'D'; I4:pi; I5:'abc2';I6: 'xyz2'; I7:'456'; I8:'WideString2')
);
//Enum testing
type
TColors = (Red, Blue, Green, Yellow, Orange, Purple, White, Black);
Size = (Small = 5, Medium = 10, Large = Small + Medium);
SomeEnum = (e1, e2, e3 = 1);
const
//set enum testing
cSetEnum = [Red,Green,Yellow];
//enum const testing
cenum: TColors = Red;
//array enum const testing
cArrayEnum1: array[0..2] of TColors = (Red, Blue,Green);
cArrayEnum2: array[SomeEnum] of TColors = (Red, Yellow);
type
//subrange testing
TMyColors = Green..White;
TMySize = Medium..Large;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -