File: math-test.adb

package info (click to toggle)
libaunit 25.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,360 kB
  • sloc: ada: 5,615; python: 243; makefile: 223; sh: 92; xml: 13
file content (40 lines) | stat: -rw-r--r-- 1,126 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--
--  Copyright (C) 2008, AdaCore
--
with AUnit.Assertions; use AUnit.Assertions;

package body Math.Test is

   procedure Test_Addition (T : in out Test) is
      pragma Unreferenced (T);
      I1 : constant Int := 5;
      I2 : constant Int := 3;
   begin
      Assert (I1 + I2 = 8, "Incorrect result after addition");
   end Test_Addition;

   procedure Test_Subtraction (T : in out Test) is
      pragma Unreferenced (T);
      I1 : constant Int := 5;
      I2 : constant Int := 3;
   begin
      Assert (I1 - I2 = 2, "Incorrect result after subtraction");
   end Test_Subtraction;

   procedure Test_Addition_Failure (T : in out Test) is
      pragma Unreferenced (T);
      I1 : constant Int := 5;
      I2 : constant Int := 3;
   begin
      Assert (I1 + I2 = 9, "Test should fail this assertion, as 5+3 /= 9");
   end Test_Addition_Failure;

   procedure Test_Addition_Error (T : in out Test) is
      pragma Unreferenced (T);
      I1 : constant Int := Int'Last;
      I2 : constant Int := Int'Last;
   begin
      Assert (I1 + I2 = I1, "This raises a constraint error");
   end Test_Addition_Error;

end Math.Test;