Skip to content

Commit 8c9eab8

Browse files
committed
[samples] updated
1 parent 9e37b74 commit 8c9eab8

File tree

5 files changed

+2193
-0
lines changed

5 files changed

+2193
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Condition="Exists('$(BDS)\bin\CodeGear.Deployment.targets')" Project="$(BDS)\bin\CodeGear.Deployment.targets"/>
3+
<ProjectExtensions>
4+
<ProjectFileVersion>12</ProjectFileVersion>
5+
</ProjectExtensions>
6+
<PropertyGroup>
7+
<DeviceId Condition="'$(Platform)'=='Android'"/>
8+
<DeviceId Condition="'$(Platform)'=='Android64'"/>
9+
<DeviceId Condition="'$(Platform)'=='iOSDevice64'"/>
10+
<DeviceId Condition="'$(Platform)'=='iOSSimulator'"/>
11+
</PropertyGroup>
12+
<ItemGroup Condition="'$(Platform)'=='iOSDevice64'"/>
13+
<ItemGroup Condition="'$(Platform)'=='Win64'"/>
14+
<ItemGroup Condition="'$(Platform)'=='Win32'">
15+
<DeployFile Include="Win32\Debug\ConditionChecks.exe" Condition="'$(Config)'=='Debug'">
16+
<RemoteDir>ConditionChecks\</RemoteDir>
17+
<RemoteName>ConditionChecks.exe</RemoteName>
18+
<DeployClass>ProjectOutput</DeployClass>
19+
<Operation>0</Operation>
20+
<LocalCommand/>
21+
<RemoteCommand/>
22+
<Overwrite>True</Overwrite>
23+
<Required>True</Required>
24+
</DeployFile>
25+
</ItemGroup>
26+
<ItemGroup Condition="'$(Platform)'=='Linux64'">
27+
<DeployFile Include="Linux64\Debug\ConditionChecks" Condition="'$(Config)'=='Debug'">
28+
<RemoteDir>ConditionChecks\</RemoteDir>
29+
<RemoteName>ConditionChecks</RemoteName>
30+
<DeployClass>ProjectOutput</DeployClass>
31+
<Operation>1</Operation>
32+
<LocalCommand/>
33+
<RemoteCommand/>
34+
<Overwrite>True</Overwrite>
35+
<Required>True</Required>
36+
</DeployFile>
37+
</ItemGroup>
38+
<ItemGroup Condition="'$(Platform)'=='OSX64'"/>
39+
<ItemGroup Condition="'$(Platform)'=='Android'"/>
40+
<ItemGroup Condition="'$(Platform)'=='iOSSimulator'">
41+
<DeployFile Include="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib">
42+
<RemoteDir>ConditionChecks.app\</RemoteDir>
43+
<RemoteName>libcgunwind.1.0.dylib</RemoteName>
44+
<DeployClass>DependencyModule</DeployClass>
45+
<Operation>1</Operation>
46+
<LocalCommand/>
47+
<RemoteCommand/>
48+
<Overwrite>True</Overwrite>
49+
</DeployFile>
50+
<DeployFile Include="$(BDS)\Redist\iossimulator\libpcre.dylib">
51+
<RemoteDir>ConditionChecks.app\</RemoteDir>
52+
<RemoteName>libpcre.dylib</RemoteName>
53+
<DeployClass>DependencyModule</DeployClass>
54+
<Operation>1</Operation>
55+
<LocalCommand/>
56+
<RemoteCommand/>
57+
<Overwrite>True</Overwrite>
58+
</DeployFile>
59+
</ItemGroup>
60+
<ItemGroup Condition="'$(Platform)'=='Android64'"/>
61+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
program ConditionChecks;
2+
3+
{$APPTYPE CONSOLE}
4+
5+
{$R *.res}
6+
7+
uses
8+
Classes,
9+
System.SysUtils,
10+
Quick.Console,
11+
Quick.Conditions;
12+
13+
type
14+
EMyException = class(Exception);
15+
16+
var
17+
result : string;
18+
num : Int64;
19+
fnum : Double;
20+
obj : TStream;
21+
22+
begin
23+
try
24+
//text must start with h and end with o
25+
result := 'Hello';
26+
Condition.Requires(result,'result')
27+
.IsNotEmpty
28+
.StartsWith('h',True)
29+
.EndsWith('o');
30+
31+
//text longer than 10 and contains check
32+
result := 'Text to check';
33+
Condition.Requires(result,'result')
34+
.IsNotEmpty
35+
.IsLongerThan(10)
36+
.Contains('check',True);
37+
38+
//text must be shorter than 10
39+
result := 'Text';
40+
Condition.Requires(result,'result')
41+
.IsNotEmpty
42+
.IsShorterThan(10);
43+
44+
//text must be not lowercase
45+
result := 'Text';
46+
Condition.Requires(result,'result')
47+
.IsNotEmpty
48+
.IsNotLowerCase;
49+
50+
//num min 1 and max 10
51+
num := 10;
52+
Condition.Requires(num,'num')
53+
.IsInRange(1,10,'value for num is out of range');
54+
55+
fnum := 7.3;
56+
Condition.Requires(fnum,'fnum')
57+
.IsGreaterThan(5)
58+
.IsLessOrEqual(8)
59+
.IsNotInRange(6,7);
60+
61+
obj := TStringStream.Create;
62+
Condition.Requires(obj,'obj')
63+
.WithExceptionOnFailure(EMyException)
64+
.IsNotNull
65+
.IsOfType(TStream)
66+
.Evaluate(obj.Size = 0);
67+
obj.Free;
68+
69+
Condition.Ensures(obj,'obj')
70+
.IsNotNull;
71+
72+
73+
cout('All conditions passed!',ccGreen);
74+
75+
ConsoleWaitForEnterKey;
76+
except
77+
on E: Exception do
78+
Writeln(E.ClassName, ': ', E.Message);
79+
end;
80+
end.

0 commit comments

Comments
 (0)