Index: tests/natools-s_expressions-templates-tests-integers.adb ================================================================== --- tests/natools-s_expressions-templates-tests-integers.adb +++ tests/natools-s_expressions-templates-tests-integers.adb @@ -20,10 +20,16 @@ with Natools.Static_Maps.S_Expressions.Templates.Integers.T; package body Natools.S_Expressions.Templates.Tests.Integers is procedure Test_Render + (Test : in out NT.Test; + Defaults : in Templates.Integers.Format; + Template : in String; + Value : in Integer; + Expected : in String); + procedure Test_Render (Test : in out NT.Test; Template : in String; Value : in Integer; Expected : in String); -- Run Template with Value and compare the result with Expected @@ -49,10 +55,29 @@ Templates.Integers.Render (Output, Parser, Value); Output.Check_Stream (Test); end Test_Render; + procedure Test_Render + (Test : in out NT.Test; + Defaults : in Templates.Integers.Format; + Template : in String; + Value : in Integer; + Expected : in String) + is + Input : aliased Test_Tools.Memory_Stream; + Output : Test_Tools.Memory_Stream; + Parser : Parsers.Stream_Parser (Input'Access); + begin + Input.Set_Data (To_Atom (Template)); + Parser.Next; + Output.Set_Expected (To_Atom (Expected)); + Templates.Integers.Render (Output, Defaults, Parser, Value); + Output.Check_Stream (Test); + end Test_Render; + + ------------------------- -- Complete Test Suite -- ------------------------- @@ -63,10 +88,11 @@ Explicit_Sign (Report); Hexadecimal (Report); Overflow (Report); Parse_Errors (Report); Static_Hash_Map (Report); + Explicit_Default_Format (Report); end All_Tests; ----------------------- -- Inidividual Tests -- @@ -100,10 +126,28 @@ Test_Render (Test, "", 42, "42"); exception when Error : others => Test.Report_Exception (Error); end Default_Format; + + procedure Explicit_Default_Format (Report : in out NT.Reporter'Class) is + Test : NT.Test := Report.Item ("Client-provided default format"); + begin + declare + Default : Templates.Integers.Format; + begin + Default.Set_Minimum_Width (2); + Default.Set_Left_Padding (To_Atom ("0")); + + Test_Render (Test, Default, "", 5, "05"); + Test_Render (Test, Default, "", 12, "12"); + Test_Render (Test, Default, "(padding 1: )", 7, " 7"); + end; + exception + when Error : others => Test.Report_Exception (Error); + end Explicit_Default_Format; + procedure Explicit_Sign (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Explicit sign specification"); begin Test_Render (Test, "(sign +)", 42, "+42"); Index: tests/natools-s_expressions-templates-tests-integers.ads ================================================================== --- tests/natools-s_expressions-templates-tests-integers.ads +++ tests/natools-s_expressions-templates-tests-integers.ads @@ -24,12 +24,13 @@ procedure All_Tests (Report : in out NT.Reporter'Class); procedure Alignment (Report : in out NT.Reporter'Class); procedure Default_Format (Report : in out NT.Reporter'Class); + procedure Explicit_Default_Format (Report : in out NT.Reporter'Class); procedure Explicit_Sign (Report : in out NT.Reporter'Class); procedure Hexadecimal (Report : in out NT.Reporter'Class); procedure Overflow (Report : in out NT.Reporter'Class); procedure Parse_Errors (Report : in out NT.Reporter'Class); procedure Static_Hash_Map (Report : in out NT.Reporter'Class); end Natools.S_Expressions.Templates.Tests.Integers;