* Generic name for Approximate to keep convention
This commit is contained in:
parent
cd6c37d326
commit
303b450036
|
@ -1,7 +1,7 @@
|
||||||
generic
|
generic
|
||||||
type Value is digits <>;
|
type Value is digits <>;
|
||||||
Absolute_Error : Value;
|
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);
|
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);
|
function ">=" (A, B : Value) return Boolean is (A >= B - Absolute_Error);
|
||||||
|
|
||||||
end VSSL.Floating_Point.Approximate_Absolute;
|
end VSSL.Floating_Point.Generic_Approximate_Absolute;
|
|
@ -1,6 +1,6 @@
|
||||||
with VSSL.Function_Test_Cases;
|
with VSSL.Function_Test_Cases;
|
||||||
use 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
|
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;
|
Abs_Error : Value_Traits.Value;
|
||||||
package Tests is
|
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 (
|
package Equals_Case is new Binary_Function_Case (
|
||||||
Value_Traits.Parent,
|
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
|
overriding procedure Run_Test (T : in out Equals_Test) is
|
||||||
begin
|
begin
|
||||||
T.Assert (0.0, 0.0, True);
|
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 * 0.5, True);
|
||||||
T.Assert (0.0, Abs_Error * 2.0, False);
|
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 Run_Test;
|
||||||
|
|
||||||
end Tests;
|
end Tests;
|
||||||
|
|
Loading…
Reference in New Issue