Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add a simple set of AUnit tests to experiment with Ada unit testing

  • Loading branch information...
commit 130b9555560ae5007a9ba4b807861b2d133d9cd2 1 parent fb50ac0
R. Tyler Croy authored
12 aunit-experiment/Makefile
... ... @@ -0,0 +1,12 @@
  1 +
  2 +all:
  3 + mkdir -p build
  4 + gprbuild -p tests.gpr
  5 +
  6 +
  7 +test: all
  8 + ./runtests
  9 +
  10 +clean:
  11 + rm -rf build
  12 + rm -f runtests
13 aunit-experiment/simpletest/runtests.adb
... ... @@ -0,0 +1,13 @@
  1 +with AUnit.Reporter.Text;
  2 +with AUnit.Run;
  3 +
  4 +with SimpleTest.Suite;
  5 +use SimpleTest.Suite;
  6 +
  7 +procedure RunTests is
  8 + procedure Runner is new AUnit.Run.Test_Runner (Suite);
  9 + Reporter : AUnit.Reporter.Text.Text_Reporter;
  10 +begin
  11 + -- Set_Use_ANSI_Colors();
  12 + Runner(Reporter);
  13 +end RunTests;
12 aunit-experiment/simpletest/simpletest-suite.adb
... ... @@ -0,0 +1,12 @@
  1 +with SimpleTest;
  2 +
  3 +
  4 +package body SimpleTest.Suite is
  5 + use AUnit.Test_Suites;
  6 + function Suite return Access_Test_Suite is
  7 + Result : constant Access_Test_Suite := new Test_Suite;
  8 + begin
  9 + Result.Add_Test(new SimpleTest.Test);
  10 + return Result;
  11 + end Suite;
  12 +end SimpleTest.Suite;
6 aunit-experiment/simpletest/simpletest-suite.ads
... ... @@ -0,0 +1,6 @@
  1 +with AUnit.Test_Suites;
  2 +use AUnit.Test_Suites;
  3 +
  4 +package SimpleTest.Suite is
  5 + function Suite return Access_Test_Suite;
  6 +end SimpleTest.Suite;
22 aunit-experiment/simpletest/simpletest.adb
... ... @@ -0,0 +1,22 @@
  1 +--
  2 +-- Simple AUnit test package body
  3 +--
  4 +
  5 +with AUnit.Assertions;
  6 +use AUnit.Assertions;
  7 +
  8 +package body SimpleTest is
  9 + function Name(T: Test) return AUnit.Message_String is
  10 + pragma Unreferenced(T);
  11 + begin
  12 + return AUnit.Format("SimpleTest package");
  13 + end Name;
  14 +
  15 + procedure Run_Test(T: In out Test) is
  16 + pragma Unreferenced(T);
  17 + begin
  18 + Assert(True, "How can True be false!");
  19 + Assert(False, "False is False, a-doy");
  20 + end Run_Test;
  21 +end SimpleTest;
  22 +
12 aunit-experiment/simpletest/simpletest.ads
... ... @@ -0,0 +1,12 @@
  1 +--
  2 +-- Simple AUnit (AdaUnit) test spec file
  3 +--
  4 +
  5 +with AUnit;
  6 +with AUnit.Simple_Test_Cases;
  7 +
  8 +package SimpleTest is
  9 + type Test is new AUnit.Simple_Test_Cases.Test_Case with null record;
  10 + function Name (T : Test) return AUnit.Message_String;
  11 + procedure Run_Test (T : in out Test);
  12 +end SimpleTest;
13 aunit-experiment/tests.gpr
... ... @@ -0,0 +1,13 @@
  1 +with "aunit";
  2 +
  3 +project Simpletest is
  4 + for Source_Dirs use ("simpletest");
  5 + for Main use ("runtests.adb");
  6 + for Object_Dir use "build";
  7 + for Exec_Dir use ".";
  8 +
  9 + package Compiler is
  10 + for Default_Switches("ada") use
  11 + ("-g", "-gnat05");
  12 + end Compiler;
  13 +end Simpletest;

0 comments on commit 130b955

Please sign in to comment.
Something went wrong with that request. Please try again.