Add a simple set of AUnit tests to experiment with Ada unit testing
This commit is contained in:
parent
fb50ac0650
commit
130b955556
|
@ -0,0 +1,12 @@
|
|||
|
||||
all:
|
||||
mkdir -p build
|
||||
gprbuild -p tests.gpr
|
||||
|
||||
|
||||
test: all
|
||||
./runtests
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
rm -f runtests
|
|
@ -0,0 +1,13 @@
|
|||
with AUnit.Reporter.Text;
|
||||
with AUnit.Run;
|
||||
|
||||
with SimpleTest.Suite;
|
||||
use SimpleTest.Suite;
|
||||
|
||||
procedure RunTests is
|
||||
procedure Runner is new AUnit.Run.Test_Runner (Suite);
|
||||
Reporter : AUnit.Reporter.Text.Text_Reporter;
|
||||
begin
|
||||
-- Set_Use_ANSI_Colors();
|
||||
Runner(Reporter);
|
||||
end RunTests;
|
|
@ -0,0 +1,12 @@
|
|||
with SimpleTest;
|
||||
|
||||
|
||||
package body SimpleTest.Suite is
|
||||
use AUnit.Test_Suites;
|
||||
function Suite return Access_Test_Suite is
|
||||
Result : constant Access_Test_Suite := new Test_Suite;
|
||||
begin
|
||||
Result.Add_Test(new SimpleTest.Test);
|
||||
return Result;
|
||||
end Suite;
|
||||
end SimpleTest.Suite;
|
|
@ -0,0 +1,6 @@
|
|||
with AUnit.Test_Suites;
|
||||
use AUnit.Test_Suites;
|
||||
|
||||
package SimpleTest.Suite is
|
||||
function Suite return Access_Test_Suite;
|
||||
end SimpleTest.Suite;
|
|
@ -0,0 +1,22 @@
|
|||
--
|
||||
-- Simple AUnit test package body
|
||||
--
|
||||
|
||||
with AUnit.Assertions;
|
||||
use AUnit.Assertions;
|
||||
|
||||
package body SimpleTest is
|
||||
function Name(T: Test) return AUnit.Message_String is
|
||||
pragma Unreferenced(T);
|
||||
begin
|
||||
return AUnit.Format("SimpleTest package");
|
||||
end Name;
|
||||
|
||||
procedure Run_Test(T: In out Test) is
|
||||
pragma Unreferenced(T);
|
||||
begin
|
||||
Assert(True, "How can True be false!");
|
||||
Assert(False, "False is False, a-doy");
|
||||
end Run_Test;
|
||||
end SimpleTest;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
--
|
||||
-- Simple AUnit (AdaUnit) test spec file
|
||||
--
|
||||
|
||||
with AUnit;
|
||||
with AUnit.Simple_Test_Cases;
|
||||
|
||||
package SimpleTest is
|
||||
type Test is new AUnit.Simple_Test_Cases.Test_Case with null record;
|
||||
function Name (T : Test) return AUnit.Message_String;
|
||||
procedure Run_Test (T : in out Test);
|
||||
end SimpleTest;
|
|
@ -0,0 +1,13 @@
|
|||
with "aunit";
|
||||
|
||||
project Simpletest is
|
||||
for Source_Dirs use ("simpletest");
|
||||
for Main use ("runtests.adb");
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
|
||||
package Compiler is
|
||||
for Default_Switches("ada") use
|
||||
("-g", "-gnat05");
|
||||
end Compiler;
|
||||
end Simpletest;
|
Loading…
Reference in New Issue