Files
fpc-msgbase/tests/testutil.pas
Ken Johnson 6181b6abce Rename to fpc-msgbase, scrub false-provenance Allfix references
Project renamed from message_api → fpc-msgbase. Folder, README title,
docs, build.sh, fpc.cfg, and test banners all updated for consistency
with the planned remote at kjgr.io:2222/kenjreno/fpc-msgbase.git.

Also scrubbed claims that backends were "ported from Allfix" or
"match Allfix's msgutil/domsg" — none of this code was ported from
Allfix; it was implemented from FTSC documents and the original
format authors' published specs (jam.txt, squish.doc, pcboard.doc,
EzyCom reference, WildCat 4 SDK headers). Author credits live in
docs/ftsc-compliance.md.

Real interop facts that mention Allfix-the-product stay documented:
the PCB Extra2 sent-bit ($40) Allfix sets when tossing, and the
FTSC-registered product code $EB. These describe external software
behavior we interoperate with, not provenance.

docs/format-notes/hudson.md removed — stale planning doc that
predates the working ma.fmt.hudson backend.
2026-04-17 12:47:43 -07:00

102 lines
2.3 KiB
ObjectPascal

{
testutil.pas - minimal assertion + reporting helpers for the
fpc-msgbase test programs. Keeps tests self-contained (no
FPCUnit dependency) so they build on every target including
go32v2 / os2 where FPCUnit may be missing.
}
unit testutil;
{$mode objfpc}{$H+}
interface
uses
SysUtils;
var
TestsRun: longint = 0;
TestsPassed: longint = 0;
TestsFailed: longint = 0;
procedure TestBegin(const AName: string);
procedure TestFail(const AMsg: string);
procedure TestOK;
procedure AssertEquals(const AName: string;
Expected, Actual: longint); overload;
procedure AssertEquals(const AName: string;
const Expected, Actual: AnsiString); overload;
procedure AssertTrue(const AName: string; Cond: boolean);
procedure AssertFalse(const AName: string; Cond: boolean);
function TestsSummary: integer;
implementation
var
CurrentTest: string;
CurrentFailed: boolean;
procedure TestBegin(const AName: string);
begin
CurrentTest := AName;
CurrentFailed := False;
Inc(TestsRun);
Write(' ', AName, ' ... ');
end;
procedure TestFail(const AMsg: string);
begin
if not CurrentFailed then begin
CurrentFailed := True;
Inc(TestsFailed);
WriteLn('FAIL');
end;
WriteLn(' ', AMsg);
end;
procedure TestOK;
begin
if not CurrentFailed then begin
Inc(TestsPassed);
WriteLn('OK');
end;
end;
procedure AssertEquals(const AName: string;
Expected, Actual: longint);
begin
if Expected <> Actual then
TestFail(Format('%s: expected %d, got %d', [AName, Expected, Actual]));
end;
procedure AssertEquals(const AName: string;
const Expected, Actual: AnsiString);
begin
if Expected <> Actual then
TestFail(Format('%s: expected "%s", got "%s"', [AName, Expected, Actual]));
end;
procedure AssertTrue(const AName: string; Cond: boolean);
begin
if not Cond then
TestFail(AName + ': expected true, got false');
end;
procedure AssertFalse(const AName: string; Cond: boolean);
begin
if Cond then
TestFail(AName + ': expected false, got true');
end;
function TestsSummary: integer;
begin
WriteLn;
WriteLn(TestsRun, ' tests, ', TestsPassed, ' passed, ',
TestsFailed, ' failed');
if TestsFailed = 0 then Result := 0 else Result := 1;
end;
end.