Index: src/natools-tests.adb ================================================================== --- src/natools-tests.adb +++ src/natools-tests.adb @@ -130,6 +130,29 @@ Info_Lists.Next (Cursor); end loop; end if; end Finalize; + + procedure Generic_Check + (Object : in out Test; + Expected : in Result; + Found : in Result; + Label : in String := "") is + begin + if Expected /= Found then + if Multiline then + Fail (Object, Label); + Info (Object, "Expected: " & Image (Expected)); + Info (Object, "Found: " & Image (Found)); + elsif Label /= "" then + Fail (Object, Label + & ": expected " & Image (Expected) + & ", found " & Image (Found)); + else + Fail (Object, "Expected " & Image (Expected) + & ", found " & Image (Found)); + end if; + end if; + end Generic_Check; + end Natools.Tests; Index: src/natools-tests.ads ================================================================== --- src/natools-tests.ads +++ src/natools-tests.ads @@ -118,10 +118,21 @@ procedure Fail (Object : in out Test; Text : in String := ""); procedure Error (Object : in out Test; Text : in String := ""); procedure Skip (Object : in out Test; Text : in String := ""); -- Set the result state and append Text info in a single call + generic + type Result (<>) is limited private; + with function "=" (Left, Right : Result) return Boolean is <>; + with function Image (Object : Result) return String is <>; + Multiline : Boolean := True; + procedure Generic_Check + (Object : in out Test; + Expected : in Result; + Found : in Result; + Label : in String := ""); + private package Info_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (String);