From 82a42674ba64c6386152a5910fd7345a92b135e8 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 21 May 2020 21:24:25 +1000 Subject: Tests complete, minor bugs fixed --- test/graph_tests.adb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/graph_tests.adb (limited to 'test/graph_tests.adb') diff --git a/test/graph_tests.adb b/test/graph_tests.adb new file mode 100644 index 0000000..321313f --- /dev/null +++ b/test/graph_tests.adb @@ -0,0 +1,34 @@ + + +package body Graph_Tests is + + + function Is_Permutation + (Left, Right : in Array_Type) + return Boolean + is + Marked_Off : array (Right'Range) of Boolean := (others => False); + Same_Count : Natural := 0; + begin + if Left'Length = 0 and Right'Length = 0 then + return True; + end if; + if Left'Length /= Right'Length then + return False; + end if; + for L in Left'Range loop + for R in Right'Range loop + if Left (L) = Right (R) and not Marked_Off (R) then + Marked_Off (R) := True; + Same_Count := Same_Count + 1; + exit; + end if; + end loop; + end loop; + return Same_Count = Left'Length; + end Is_Permutation; + + +end Graph_Tests; + + -- cgit