Skip to content

Commit

Permalink
Add a simple set of AUnit tests to experiment with Ada unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Tyler Croy committed Nov 8, 2010
1 parent fb50ac0 commit 130b955
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 0 deletions.
12 changes: 12 additions & 0 deletions aunit-experiment/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

all:
mkdir -p build
gprbuild -p tests.gpr


test: all
./runtests

clean:
rm -rf build
rm -f runtests
13 changes: 13 additions & 0 deletions aunit-experiment/simpletest/runtests.adb
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions aunit-experiment/simpletest/simpletest-suite.adb
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 6 additions & 0 deletions aunit-experiment/simpletest/simpletest-suite.ads
Original file line number Diff line number Diff line change
@@ -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;
22 changes: 22 additions & 0 deletions aunit-experiment/simpletest/simpletest.adb
Original file line number Diff line number Diff line change
@@ -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;

12 changes: 12 additions & 0 deletions aunit-experiment/simpletest/simpletest.ads
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 13 additions & 0 deletions aunit-experiment/tests.gpr
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 130b955

Please sign in to comment.