Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions includes/Common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@
// КОД СЛЕДУЮЩИЙ НИЖЕ НЕ ПРЕДНАЗНАЧЕН ДЛЯ ИЗМЕНЕНИЯ ПРОГРАММИСТОМ И
// СОДЕРЖИТ КРИТИЧЕСКИЕ НАСТРОЙКИ ДЛЯ БИБЛИОТЕКИ CryptoHash

{$ALIGN 8} // Record fields alignment
{$SCOPEDENUMS ON} // Use enum values only with enum type
{$WRITEABLECONST OFF} // {$J-}
{$OVERFLOWCHECKS OFF} // {$Q-}
{$RANGECHECKS OFF} // {$R-}
{$TYPEDADDRESS ON} // {$T+}
{$BOOLEVAL OFF} // {$B-}
{$SAFEDIVIDE OFF} // {$U-}
{$RANGECHECKS OFF} // {$R-}
{$TYPEDADDRESS ON} // {$T+}
{$BOOLEVAL OFF} // {$B-}
{$SAFEDIVIDE OFF} // {$U-}
{$EXTENDEDSYNTAX ON} // {$X+}

{$IF DEFINED(DEBUG)}
{$DEBUGINFO ON} // {$D+}
{$DEBUGINFO ON} // {$D+}
{$LOCALSYMBOLS ON} // {$L+}
{$OPTIMIZATION OFF} // {$O-}
{$ASSERTIONS ON} // {$C+}
{$STACKFRAMES ON} // {$W+}
{$INLINE OFF}
{$ASSERTIONS ON} // {$C+}
{$STACKFRAMES ON} // {$W+}
{$INLINE OFF} // inline methods are used as usual
{$ELSE ~ NOT DEBUG}
{$DEBUGINFO OFF} // {$D-}
{$DEBUGINFO OFF} // {$D-}
{$LOCALSYMBOLS OFF} // {$L-}
{$OPTIMIZATION ON} // {$O+}
{$ASSERTIONS OFF} // {$C-}
{$STACKFRAMES OFF} // {$W-}
{$INLINE ON}
{$ASSERTIONS OFF} // {$C-}
{$STACKFRAMES OFF} // {$W-}
{$INLINE ON} // inline methods are built into the code as part of it
{$ENDIF ~ DEBUG}

{$ENDIF ~ COMMON_INC}
4 changes: 0 additions & 4 deletions tests/includes/Common.Tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
{$IF NOT DEFINED(COMMON_TESTS_INC)}
{$DEFINE COMMON_TESTS_INC}

// Если используется QuickLib (https://github.com/exilon/QuickLib),
// необходимо включить эту опцию
//{$DEFINE USE_QUICK_LIB}

// Управление исполнителями тестов, включать можно только один одновременно.
// Если ни один не включен, тесты будут исполняться в косольном режиме
//{$DEFINE USE_VCL_TESTRUNNER}
Expand Down
26 changes: 26 additions & 0 deletions tests/includes/Utils4D.Tests.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************//
//* Project : localizations *//
//* Latest Source: https://github.com/vampirsoft/localizations *//
//* Unit Name : Utils4D.Tests.inc *//
//* Author : Сергей (LordVampir) Дворников *//
//* Copyright 2024 LordVampir (https://github.com/vampirsoft) *//
//* Licensed under MIT *//
//*****************************************************************************//
/////////////////////////////////////////////////////////////////////////////////

{$IF NOT DEFINED(UTILS_4_D_TESTS_INC)}
{$DEFINE UTILS_4_D_TESTS_INC}

// Если используется QuickLib (https://github.com/exilon/QuickLib),
// необходимо включить эту опцию
//{$DEFINE USE_QUICK_LIB}

// ВНИМАНИЕ!!!
// =============================================================================
// КОД СЛЕДУЮЩИЙ НИЖЕ НЕ ПРЕДНАЗНАЧЕН ДЛЯ ИЗМЕНЕНИЯ ПРОГРАММИСТОМ И
// СОДЕРЖИТ КРИТИЧЕСКИЕ НАСТРОЙКИ

{$INCLUDE Common.Tests.inc}

{$ENDIF ~ UTILS_4_D_TESTS_INC}
65 changes: 3 additions & 62 deletions tests/packages/utils4d.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,14 @@

program utils4d;

{$INCLUDE Common.Tests.inc}
{$INCLUDE Utils4D.Tests.inc}

{$IFDEF CONSOLE_TESTRUNNER}
{$APPTYPE CONSOLE}
{$ENDIF}

uses
System.SysUtils,
{$IFDEF CONSOLE_TESTRUNNER}
DUnitX.Loggers.Console,
DUnitX.Loggers.Xml.NUnit,
{$ENDIF CONSOLE_TESTRUNNER}
{$IFDEF USE_VCL_TESTRUNNER}
Vcl.Forms,
DUnitX.Loggers.GUI.VCL,
{$ENDIF USE_VCL_TESTRUNNER}
{$IFDEF USE_MOBILE_TESTRUNNER}
FMX.Forms,
DUNitX.Loggers.MobileGUI,
{$ENDIF USE_MOBILE_TESTRUNNER}
DUnitX.TestFramework,
DUnitXTestRunner in '..\sources\DUnitXTestRunner.pas',
Utils.ExtArray in '..\..\sources\Utils.ExtArray.pas',
Utils.Arrays.Helper in '..\..\sources\Utils.Arrays.Helper.pas',
Utils.ExtArray.Tests in '..\sources\Utils.ExtArray.Tests.pas',
Expand All @@ -40,51 +27,5 @@ uses
{$R *.RES}

begin
ReportMemoryLeaksOnShutdown := True;
{$IFDEF CONSOLE_TESTRUNNER}
try
//Check command line options, will exit if invalid
TDUnitX.CheckCommandLine;
//Create the test runner
const Runner = TDUnitX.CreateRunner;
//Tell the runner to use RTTI to find Fixtures
Runner.UseRTTI := True;
//When true, Assertions must be made during tests;
Runner.FailsOnNoAsserts := False;

//tell the runner how we will log things
//Log to the console window if desired
if TDUnitX.Options.ConsoleMode <> TDunitXConsoleMode.Off then
begin
const Logger = TDUnitXConsoleLogger.Create(TDUnitX.Options.ConsoleMode = TDunitXConsoleMode.Quiet);
Runner.AddLogger(Logger);
end;
//Generate an NUnit compatible XML File
const NUnitLogger = TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
Runner.AddLogger(NUnitLogger);

//Run tests
const Results = Runner.Execute;
if not Results.AllPassed then
System.ExitCode := EXIT_ERRORS;

//We don't want this happening when running under CI.
TDUnitX.Options.ExitBehavior := TDUnitXExitBehavior.Pause;
System.Write('Done... press <Enter> key to quit.');
System.Readln;
except
on E: Exception do
System.Writeln(E.ClassName, ': ', E.Message);
end;
{$ENDIF CONSOLE_TESTRUNNER}
{$IFDEF USE_VCL_TESTRUNNER}
Application.Initialize;
Application.CreateForm(TGUIVCLTestRunner, GUIVCLTestRunner);
Application.Run;
{$ENDIF USE_VCL_TESTRUNNER}
{$IFDEF USE_MOBILE_TESTRUNNER}
Application.Initialize;
Application.CreateForm(TMobileGUITestRunner, MobileGUITestRunner);
Application.Run;
{$ENDIF USE_MOBILE_TESTRUNNER}
RunRegisteredTests;
end.
8 changes: 8 additions & 0 deletions tests/packages/utils4d.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="..\sources\DUnitXTestRunner.pas"/>
<DCCReference Include="..\..\sources\Utils.ExtArray.pas"/>
<DCCReference Include="..\..\sources\Utils.Arrays.Helper.pas"/>
<DCCReference Include="..\sources\Utils.ExtArray.Tests.pas"/>
<DCCReference Include="..\sources\Utils.Arrays.Helper.Tests.pas"/>
<None Include="..\includes\Common.Tests.inc"/>
<None Include="..\includes\Utils4D.Tests.inc"/>
<None Include="..\..\includes\Common.inc"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
Expand Down Expand Up @@ -247,6 +249,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="..\includes\Utils4D.Tests.inc" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator">
<Operation>1</Operation>
Expand Down
89 changes: 89 additions & 0 deletions tests/sources/DUnitXTestRunner.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************//
//* Project : utils4d *//
//* Latest Source: https://github.com/vampirsoft/utils4d *//
//* Unit Name : DUnitXTestRunner.pas *//
//* Author : Сергей (LordVampir) Дворников *//
//* Copyright 2024 LordVampir (https://github.com/vampirsoft) *//
//* Licensed under MIT *//
//*****************************************************************************//
/////////////////////////////////////////////////////////////////////////////////

unit DUnitXTestRunner;

{$INCLUDE Common.Tests.inc}

interface

procedure RunRegisteredTests;

implementation

uses
System.SysUtils,
{$IFDEF CONSOLE_TESTRUNNER}
DUnitX.Loggers.Console,
DUnitX.Loggers.Xml.NUnit,
{$ENDIF CONSOLE_TESTRUNNER}
{$IFDEF USE_VCL_TESTRUNNER}
Vcl.Forms,
DUnitX.Loggers.GUI.VCL,
{$ENDIF USE_VCL_TESTRUNNER}
{$IFDEF USE_MOBILE_TESTRUNNER}
FMX.Forms,
DUNitX.Loggers.MobileGUI,
{$ENDIF USE_MOBILE_TESTRUNNER}
DUnitX.TestFramework;

procedure RunRegisteredTests;
begin
ReportMemoryLeaksOnShutdown := True;

{$IFDEF CONSOLE_TESTRUNNER}
try
//Check command line options, will exit if invalid
TDUnitX.CheckCommandLine;
//Create the test runner
const Runner = TDUnitX.CreateRunner;
//Tell the runner to use RTTI to find Fixtures
Runner.UseRTTI := True;
//When true, Assertions must be made during tests;
Runner.FailsOnNoAsserts := False;

//tell the runner how we will log things
//Log to the console window if desired
if TDUnitX.Options.ConsoleMode <> TDunitXConsoleMode.Off then
begin
const Logger = TDUnitXConsoleLogger.Create(TDUnitX.Options.ConsoleMode = TDunitXConsoleMode.Quiet);
Runner.AddLogger(Logger);
end;
//Generate an NUnit compatible XML File
const NUnitLogger = TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
Runner.AddLogger(NUnitLogger);

//Run tests
const Results = Runner.Execute;
if not Results.AllPassed then System.ExitCode := EXIT_ERRORS;

//We don't want this happening when running under CI.
TDUnitX.Options.ExitBehavior := TDUnitXExitBehavior.Pause;
System.Write('Done... press <Enter> key to quit.');
except
on E: Exception do
System.Writeln(E.ClassName, ': ', E.Message);
end;
System.Readln;
{$ENDIF CONSOLE_TESTRUNNER}
{$IFDEF USE_VCL_TESTRUNNER}
Application.Initialize;
Application.CreateForm(TGUIVCLTestRunner, GUIVCLTestRunner);
Application.Run;
{$ENDIF USE_VCL_TESTRUNNER}
{$IFDEF USE_MOBILE_TESTRUNNER}
Application.Initialize;
Application.CreateForm(TMobileGUITestRunner, MobileGUITestRunner);
Application.Run;
{$ENDIF USE_MOBILE_TESTRUNNER}
end;

end.
2 changes: 1 addition & 1 deletion tests/sources/Utils.Arrays.Helper.Tests.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

unit Utils.Arrays.Helper.Tests;

{$INCLUDE Common.Tests.inc}
{$INCLUDE Utils4D.Tests.inc}

interface

Expand Down
2 changes: 1 addition & 1 deletion tests/sources/Utils.ExtArray.Tests.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

unit Utils.ExtArray.Tests;

{$INCLUDE Common.Tests.inc}
{$INCLUDE Utils4D.Tests.inc}

interface

Expand Down