unit TestCase1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry;
type
{ TTestCase_Math }
TTestCase_Math= class(TTestCase)
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestHookUp;
end;
implementation
procedure TTestCase_Math.TestHookUp;
begin
Fail('Scrivi il tuo test');
end;
procedure TTestCase_Math.SetUp;
begin
end;
procedure TTestCase_Math.TearDown;
begin
end;
initialization
RegisterTest(TTestCase_Math);
end.
unit TestCase1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry;
type
{ TTestCase_Math }
TTestCase_Math= class(TTestCase)
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestHookUp;
procedure TestSum();
procedure TestDifference();
procedure TestMultiply();
procedure TestDivide();
end;
implementation
procedure TTestCase_Math.TestHookUp;
begin
Fail('Scrivi il tuo test');
end;
procedure TTestCase_Math.TestSum();
begin
CheckEquals(5, 6,'Sum incorrect');
end;
procedure TTestCase_Math.TestDifference();
begin
CheckEquals(3, 4,'Difference incorrect');
end;
procedure TTestCase_Math.TestMultiply();
begin
CheckEquals(8, 6,'Multiply incorrect');
end;
procedure TTestCase_Math.TestDivide();
begin
CheckEquals(2, 3,'Difference incorrect');
end;
procedure TTestCase_Math.SetUp;
begin
end;
procedure TTestCase_Math.TearDown;
begin
end;
initialization
RegisterTest(TTestCase_Math);
end.
unit uMath;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
{ TMath }
TMath = class
private
public
constructor Create;
destructor Free;
function Sum(a : integer; b : integer) : integer;
function Difference(a : integer; b : integer) : integer;
function Multiply(a : integer; b : integer) : integer;
function Divide(a : integer; b : integer) : single;
end;
implementation
{ TMath }
constructor TMath.Create;
begin
end;
destructor TMath.Free;
begin
end;
function TMath.Sum(a: integer; b: integer): integer;
begin
result := a + b;
end;
function TMath.Difference(a: integer; b: integer): integer;
begin
result := a - b;
end;
function TMath.Multiply(a: integer; b: integer): integer;
begin
result := a * b;
end;
function TMath.Divide(a: integer; b: integer): single;
begin
result := a / b;
end;
end.
unit TestCase1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry, uMath;
type
{ TTestCase_Math }
TTestCase_Math= class(TTestCase)
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestHookUp;
procedure TestSum();
procedure TestDifference();
procedure TestMultiply();
procedure TestDivide();
end;
implementation
procedure TTestCase_Math.TestHookUp;
begin
Fail('Scrivi il tuo test');
end;
procedure TTestCase_Math.TestSum();
var
app : TMath;
begin
app := TMath.Create;
CheckEquals(5, app.Sum(4, 1),'Sum incorrect');
app.Free;
app := nil;
end;
procedure TTestCase_Math.TestDifference();
var
app : TMath;
begin
app := TMath.Create;
CheckEquals(3, app.Difference(4, 1),'Difference incorrect');
app.Free;
app := nil;
end;
procedure TTestCase_Math.TestMultiply();
var
app : TMath;
begin
app := TMath.Create;
CheckEquals(8, app.Multiply(4, 2),'Multiply incorrect');
app.Free;
app := nil;
end;
procedure TTestCase_Math.TestDivide();
var
app : TMath;
begin
app := TMath.Create;
CheckEquals(2, app.Divide(4, 2),'Divide incorrect');
app.Free;
app := nil;
end;
procedure TTestCase_Math.SetUp;
begin
end;
procedure TTestCase_Math.TearDown;
begin
end;
initialization
RegisterTest(TTestCase_Math);
end.