const str optimization
This commit is contained in:
@@ -3,11 +3,12 @@ program Project2;
|
||||
{$IFNDEF TESTINSIGHT}
|
||||
{$APPTYPE CONSOLE}
|
||||
{$ENDIF}{$STRONGLINKTYPES ON}
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
{$IFDEF TESTINSIGHT}
|
||||
{$IFDEF TESTINSIGHT}
|
||||
TestInsight.DUnitX,
|
||||
{$ENDIF }
|
||||
{$ENDIF }
|
||||
DUnitX.Loggers.Console,
|
||||
DUnitX.Loggers.Xml.NUnit,
|
||||
DUnitX.TestFramework,
|
||||
@@ -15,46 +16,50 @@ uses
|
||||
AG.Logs in '..\AG.Logs.pas';
|
||||
|
||||
var
|
||||
runner : ITestRunner;
|
||||
results : IRunResults;
|
||||
logger : ITestLogger;
|
||||
nunitLogger : ITestLogger;
|
||||
runner: ITestRunner;
|
||||
results: IRunResults;
|
||||
logger: ITestLogger;
|
||||
nunitLogger: ITestLogger;
|
||||
|
||||
begin
|
||||
{$IFDEF TESTINSIGHT}
|
||||
TestInsight.DUnitX.RunRegisteredTests;
|
||||
exit;
|
||||
{$ENDIF}
|
||||
try
|
||||
//Check command line options, will exit if invalid
|
||||
// Check command line options, will exit if invalid
|
||||
TDUnitX.CheckCommandLine;
|
||||
//Create the test runner
|
||||
// Create the test runner
|
||||
runner := TDUnitX.CreateRunner;
|
||||
//Tell the runner to use RTTI to find Fixtures
|
||||
// Tell the runner to use RTTI to find Fixtures
|
||||
runner.UseRTTI := True;
|
||||
//tell the runner how we will log things
|
||||
//Log to the console window
|
||||
logger := TDUnitXConsoleLogger.Create(true);
|
||||
// tell the runner how we will log things
|
||||
// Log to the console window
|
||||
logger := TDUnitXConsoleLogger.Create(True);
|
||||
runner.AddLogger(logger);
|
||||
//Generate an NUnit compatible XML File
|
||||
nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
|
||||
// Generate an NUnit compatible XML File
|
||||
nunitLogger := TDUnitXXMLNUnitFileLogger.Create
|
||||
(TDUnitX.Options.XMLOutputFile);
|
||||
runner.AddLogger(nunitLogger);
|
||||
runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;
|
||||
runner.FailsOnNoAsserts := False;
|
||||
// When true, Assertions must be made during tests;
|
||||
|
||||
//Run tests
|
||||
// Run tests
|
||||
results := runner.Execute;
|
||||
if not results.AllPassed then
|
||||
System.ExitCode := EXIT_ERRORS;
|
||||
|
||||
{$IFNDEF CI}
|
||||
//We don't want this happening when running under CI.
|
||||
{$IFNDEF CI}
|
||||
// We don't want this happening when running under CI.
|
||||
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
|
||||
begin
|
||||
System.Write('Done.. press <Enter> key to quit.');
|
||||
System.Readln;
|
||||
end;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
except
|
||||
on E: Exception do
|
||||
System.Writeln(E.ClassName, ': ', E.Message);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@@ -81,6 +81,8 @@
|
||||
<DCC_RemoteDebug>true</DCC_RemoteDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
|
||||
<Manifest_File>None</Manifest_File>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<DCC_RemoteDebug>false</DCC_RemoteDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
@@ -115,6 +117,10 @@
|
||||
<Source>
|
||||
<Source Name="MainSource">Project2.dpr</Source>
|
||||
</Source>
|
||||
<Excluded_Packages>
|
||||
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k220.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||
<Excluded_Packages Name="$(BDSBIN)\dclofficexp220.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||
</Excluded_Packages>
|
||||
</Delphi.Personality>
|
||||
<Deployment Version="1">
|
||||
<DeployFile LocalName="Win32\Debug\Project2.exe" Configuration="Debug" Class="ProjectOutput">
|
||||
@@ -451,13 +457,13 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||
</Deployment>
|
||||
<Platforms>
|
||||
<Platform value="OSX32">True</Platform>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
unit Unit2;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
DUnitX.TestFramework,AG.Logs,System.Classes,System.IOUtils,System.SysUtils,Winapi.Windows;
|
||||
DUnitX.TestFramework, AG.Logs, System.Classes, System.IOUtils,
|
||||
System.SysUtils, Winapi.Windows;
|
||||
|
||||
type
|
||||
|
||||
@@ -20,32 +22,34 @@ implementation
|
||||
|
||||
procedure TMyTestObject.Test1;
|
||||
var
|
||||
MultiLog:TAGLog;
|
||||
Stream:TStream;
|
||||
s:TBytes;
|
||||
MultiLog: TAGLog;
|
||||
Stream: TStream;
|
||||
s: TBytes;
|
||||
begin
|
||||
MultiLog:=TAGMultiLog.Create(nil);
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGNullLog.Create());
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGDiskLog.Create('test.log'));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGRamLog.Create());
|
||||
MultiLog := TAGMultiLog.Create(nil);
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGNullLog.Create());
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGDiskLog.Create('test.log'));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGRamLog.Create());
|
||||
{$IFNDEF MSWINDOWS}(MultiLog as TAGMultiLog).Logs.Add(TAGCommandLineLog.Create(GetStdHandle(STD_OUTPUT_HANDLE))){$ENDIF};
|
||||
try
|
||||
s:=TFile.ReadAllBytes('test2.log');
|
||||
except
|
||||
s:=TBytes.Create();
|
||||
end;
|
||||
Stream:=TFileStream.Create('test2.log',fmCreate+fmOpenReadWrite+fmShareDenyWrite);
|
||||
Stream.WriteBuffer(s,length(s));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGStreamLog.Create(Stream));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGCallBackLog.Create(procedure(s:string)
|
||||
begin
|
||||
Self.WriteLn(s);
|
||||
end));{}
|
||||
MultiLog.Write('Str Test');
|
||||
MultiLog.Write('Str+Object Test',self);
|
||||
FreeAndNil(MultiLog);
|
||||
try
|
||||
s := TFile.ReadAllBytes('test2.log');
|
||||
except
|
||||
s := TBytes.Create();
|
||||
end;
|
||||
Stream := TFileStream.Create('test2.log', fmCreate + fmOpenReadWrite +
|
||||
fmShareDenyWrite);
|
||||
Stream.WriteBuffer(s, length(s));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGStreamLog.Create(Stream));
|
||||
(MultiLog as TAGMultiLog)
|
||||
.Logs.Add(TAGCallBackLog.Create(procedure(s: string)
|
||||
begin Self.WriteLn(s); end)); { }
|
||||
MultiLog.Write('Str Test');
|
||||
MultiLog.Write('Str+Object Test', Self);
|
||||
FreeAndNil(MultiLog);
|
||||
end;
|
||||
|
||||
initialization
|
||||
TDUnitX.RegisterTestFixture(TMyTestObject);
|
||||
|
||||
TDUnitX.RegisterTestFixture(TMyTestObject);
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user