diff --git a/source/library/vssl-floating_point-approximate_absolute.ads b/source/library/vssl-floating_point-generic_approximate_absolute.ads similarity index 80% rename from source/library/vssl-floating_point-approximate_absolute.ads rename to source/library/vssl-floating_point-generic_approximate_absolute.ads index bfe856c..28a68f8 100644 --- a/source/library/vssl-floating_point-approximate_absolute.ads +++ b/source/library/vssl-floating_point-generic_approximate_absolute.ads @@ -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; \ No newline at end of file +end VSSL.Floating_Point.Generic_Approximate_Absolute; \ No newline at end of file diff --git a/source/test/vssl-floating_point-approximate_absolute_test.adb b/source/test/vssl-floating_point-approximate_absolute_test.adb index 2238bf2..63e3ef1 100644 --- a/source/test/vssl-floating_point-approximate_absolute_test.adb +++ b/source/test/vssl-floating_point-approximate_absolute_test.adb @@ -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;