Index: tests/natools-s_expressions-test_tools.adb ================================================================== --- tests/natools-s_expressions-test_tools.adb +++ tests/natools-s_expressions-test_tools.adb @@ -128,16 +128,46 @@ Report.Info ('"' & To_String (Data) & '"'); end if; else if Label'Length > 0 then Report.Info - (Label & ": " & Natural'Image (Data'Length) & " octets"); + (Label & ":" & Natural'Image (Data'Length) & " octets"); end if; while I < Data'Length loop Length := Offset'Min (16, Data'Length - I); Report.Info (Hex_Slice + (I, 8, + Data (Data'First + I .. Data'First + I + Length - 1), 16)); + I := I + 16; + end loop; + end if; + end Dump_Atom; + + + procedure Dump_Atom -- Cut and pasted code because generics crash gnat + (Test : in out NT.Test; + Data : in Atom; + Label : in String := "") + is + I, Length : Offset := 0; + begin + if Is_Printable (Data) then + if Label'Length > 0 then + Test.Info (Label & ": """ & To_String (Data) & '"'); + else + Test.Info ('"' & To_String (Data) & '"'); + end if; + else + if Label'Length > 0 then + Test.Info + (Label & ":" & Natural'Image (Data'Length) & " octets"); + end if; + + while I < Data'Length loop + Length := Offset'Min (16, Data'Length - I); + Test.Info (Hex_Slice (I, 8, Data (Data'First + I .. Data'First + I + Length - 1), 16)); I := I + 16; end loop; end if; @@ -157,10 +187,23 @@ Dump_Atom (Report, Found, "Found"); Dump_Atom (Report, Expected, "Expected"); end if; end Test_Atom; + + procedure Test_Atom + (Test : in out NT.Test; + Expected : in Atom; + Found : in Atom) is + begin + if Found /= Expected then + Test.Fail; + Dump_Atom (Test, Found, "Found"); + Dump_Atom (Test, Expected, "Expected"); + end if; + end Test_Atom; + ------------------- -- Memory Stream -- ------------------- Index: tests/natools-s_expressions-test_tools.ads ================================================================== --- tests/natools-s_expressions-test_tools.ads +++ tests/natools-s_expressions-test_tools.ads @@ -34,19 +34,27 @@ package NT renames Natools.Tests; procedure Dump_Atom (Report : in out NT.Reporter'Class; + Data : in Atom; + Label : in String := ""); + procedure Dump_Atom + (Test : in out NT.Test; Data : in Atom; Label : in String := ""); -- Dump contents on Data as info in Report procedure Test_Atom (Report : in out NT.Reporter'Class; Test_Name : in String; Expected : in Atom; Found : in Atom); + procedure Test_Atom + (Test : in out NT.Test; + Expected : in Atom; + Found : in Atom); -- Report success when Found is equal to Expected, and failure -- with diagnostics otherwise. type Memory_Stream is new Ada.Streams.Root_Stream_Type with private;