summaryrefslogtreecommitdiff
path: root/test/ratnest-tests.adb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ratnest-tests.adb')
-rw-r--r--test/ratnest-tests.adb116
1 files changed, 116 insertions, 0 deletions
diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb
index 2479998..3309b2a 100644
--- a/test/ratnest-tests.adb
+++ b/test/ratnest-tests.adb
@@ -3,6 +3,7 @@
with
Ada.Characters.Latin_1,
+ Ada.Strings.Maps,
Packrat.Util;
@@ -10,11 +11,126 @@ package body Ratnest.Tests is
package Latin renames Ada.Characters.Latin_1;
+ package Strmaps renames Ada.Strings.Maps;
package PU renames Packrat.Util;
+
+ function In_Set_Check
+ return Test_Result
+ is
+ use type Strmaps.Character_Set;
+ Set_1 : Strmaps.Character_Set := Strmaps.To_Set ("abcxyz");
+ Set_2 : Strmaps.Character_Set := Strmaps.To_Set ("!""#$");
+ function Func_1 is new PU.In_Set (Set_1);
+ function Func_2 is new PU.In_Set (Set_2);
+ begin
+ -- Func_1 testing
+ for I in Integer range Character'Pos (Character'First) .. Character'Pos ('a') - 1 loop
+ if Func_1 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ for C in Character range 'a' .. 'c' loop
+ if not Func_1 (C) then
+ return Failure;
+ end if;
+ end loop;
+ for I in Integer range Character'Pos ('c') + 1 .. Character'Pos ('x') - 1 loop
+ if Func_1 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ for C in Character range 'x' .. 'z' loop
+ if not Func_1 (C) then
+ return Failure;
+ end if;
+ end loop;
+ for I in Integer range Character'Pos ('z') + 1 .. Character'Pos (Character'Last) loop
+ if Func_1 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ -- Func_2 testing
+ for I in Integer range Character'Pos (Character'First) .. Character'Pos ('!') - 1 loop
+ if Func_2 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ for C in Character range '!' .. '$' loop
+ if not Func_2 (C) then
+ return Failure;
+ end if;
+ end loop;
+ for I in Integer range Character'Pos ('$') + 1 .. Character'Pos (Character'Last) loop
+ if Func_2 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ return Success;
+ end In_Set_Check;
+
+
+ function Not_In_Set_Check
+ return Test_Result
+ is
+ use type Strmaps.Character_Set;
+ Set_1 : Strmaps.Character_Set := Strmaps.To_Set ("abcxyz");
+ Set_2 : Strmaps.Character_Set := Strmaps.To_Set ("!""#$");
+ function Func_1 is new PU.Not_In_Set (Set_1);
+ function Func_2 is new PU.Not_In_Set (Set_2);
+ begin
+ -- Func_1 testing
+ for I in Integer range Character'Pos (Character'First) .. Character'Pos ('a') - 1 loop
+ if not Func_1 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ for C in Character range 'a' .. 'c' loop
+ if Func_1 (C) then
+ return Failure;
+ end if;
+ end loop;
+ for I in Integer range Character'Pos ('c') + 1 .. Character'Pos ('x') - 1 loop
+ if not Func_1 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ for C in Character range 'x' .. 'z' loop
+ if Func_1 (C) then
+ return Failure;
+ end if;
+ end loop;
+ for I in Integer range Character'Pos ('z') + 1 .. Character'Pos (Character'Last) loop
+ if not Func_1 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ -- Func_2 testing
+ for I in Integer range Character'Pos (Character'First) .. Character'Pos ('!') - 1 loop
+ if not Func_2 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ for C in Character range '!' .. '$' loop
+ if Func_2 (C) then
+ return Failure;
+ end if;
+ end loop;
+ for I in Integer range Character'Pos ('$') + 1 .. Character'Pos (Character'Last) loop
+ if not Func_2 (Character'Val (I)) then
+ return Failure;
+ end if;
+ end loop;
+ return Success;
+ end Not_In_Set_Check;
+
+
+
+
+
function Is_Digit_Check
return Test_Result is
begin