* Generic name for Approximate to keep convention

This commit is contained in:
Vovanium 2023-03-08 00:24:12 +03:00
parent cd6c37d326
commit 303b450036
2 changed files with 11 additions and 4 deletions

View File

@ -1,7 +1,7 @@
generic
type Value is digits <>;
Absolute_Error : Value;
package VSSL.Floating_Point.Approximate_Absolute is
package VSSL.Floating_Point.Generic_Approximate_Absolute is
function "=" (A, B : Value) return Boolean is (A in B - Absolute_Error .. B + Absolute_Error);
@ -13,4 +13,4 @@ package VSSL.Floating_Point.Approximate_Absolute is
function ">=" (A, B : Value) return Boolean is (A >= B - Absolute_Error);
end VSSL.Floating_Point.Approximate_Absolute;
end VSSL.Floating_Point.Generic_Approximate_Absolute;

View File

@ -1,6 +1,6 @@
with VSSL.Function_Test_Cases;
use VSSL.Function_Test_Cases;
with VSSL.Floating_Point.Approximate_Absolute;
with VSSL.Floating_Point.Generic_Approximate_Absolute;
package body VSSL.Floating_Point.Approximate_Absolute_Test is
@ -22,7 +22,7 @@ package body VSSL.Floating_Point.Approximate_Absolute_Test is
Abs_Error : Value_Traits.Value;
package Tests is
package Approx is new Approximate_Absolute (Value_Traits.Value, Abs_Error);
package Approx is new Generic_Approximate_Absolute (Value_Traits.Value, Abs_Error);
package Equals_Case is new Binary_Function_Case (
Value_Traits.Parent,
@ -42,8 +42,15 @@ package body VSSL.Floating_Point.Approximate_Absolute_Test is
overriding procedure Run_Test (T : in out Equals_Test) is
begin
T.Assert (0.0, 0.0, True);
T.Assert (1.0, 1.0, True);
T.Assert (0.0, Abs_Error * 0.5, True);
T.Assert (0.0, Abs_Error * 2.0, False);
T.Assert (0.0, -Abs_Error * 0.5, True);
T.Assert (0.0, -Abs_Error * 2.0, False);
T.Assert (1.0, 1.0 + Abs_Error * 0.5, True);
T.Assert (1.0, 1.0 + Abs_Error * 2.0, False);
T.Assert (1.0, 1.0 - Abs_Error * 0.5, True);
T.Assert (1.0, 1.0 - Abs_Error * 2.0, False);
end Run_Test;
end Tests;