Natools

Check-in [6f0dd49985]
Login
Overview
Comment:s_expressions-templates-tests: a simple tests for discrete-type templates
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6f0dd49985fa3cf5a92978f26e3799baa8a59257
User & Date: nat on 2014-09-18 20:08:17
Other Links: manifest | tags
Context
2014-09-19
19:20
s_expressions-templates-generic_integers: add public mutators for Format objects check-in: 61b64dbec7 user: nat tags: trunk
2014-09-18
20:08
s_expressions-templates-tests: a simple tests for discrete-type templates check-in: 6f0dd49985 user: nat tags: trunk
2014-09-17
21:07
s_expressions-templates-generic_discrete_render: new generic procedure for rendering values of discrete types check-in: 592c7cfd1a user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-templates-tests.adb from [f2f7ff5595] to [c58c6a5938].

10
11
12
13
14
15
16


17

18
19






20
21
22
23
24
25
26

27
28
29
30
31
32
33


































34
35
36
37
38
39
40
41
42
43
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------



with Natools.S_Expressions.Templates.Tests.Integers;


package body Natools.S_Expressions.Templates.Tests is







   -------------------------
   -- Complete Test Suite --
   -------------------------

   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin

      Test_Integers (Report);
   end All_Tests;


   --------------------------------------
   -- Inidividual Children Test Suites --
   --------------------------------------



































   procedure Test_Integers (Report : in out NT.Reporter'Class) is
   begin
      Report.Section ("Integer templates");
      Natools.S_Expressions.Templates.Tests.Integers.All_Tests (Report);
      Report.End_Section;
   end Test_Integers;

end Natools.S_Expressions.Templates.Tests;








>
>

>


>
>
>
>
>
>







>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

with Natools.S_Expressions.Parsers;
with Natools.S_Expressions.Templates.Generic_Discrete_Render;
with Natools.S_Expressions.Templates.Tests.Integers;
with Natools.S_Expressions.Test_Tools;

package body Natools.S_Expressions.Templates.Tests is

   type Day_Name is (Monday, Tuesday, Wednesday, Thursday,
       Friday, Saturday, Sunday);

   procedure Day_Render is new Generic_Discrete_Render (Day_Name);


   -------------------------
   -- Complete Test Suite --
   -------------------------

   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Test_Discrete (Report);
      Test_Integers (Report);
   end All_Tests;


   --------------------------------------
   -- Inidividual Children Test Suites --
   --------------------------------------

   procedure Test_Discrete (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Discrete templates");

      procedure Render_Test
        (Template : in String;
         Value : in Day_Name;
         Expected : in String);

      procedure Render_Test
        (Template : in String;
         Value : in Day_Name;
         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));
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Parser.Next;
         Output.Set_Expected (To_Atom (Expected));
         Day_Render (Output, Parser, Value);
         Output.Check_Stream (Test);
      end Render_Test;
   begin
      Render_Test ("(a b)", Friday, "FRIDAY");
      Render_Test ("(a b)", Monday, "a");
      Render_Test ("(a b)", Tuesday, "b");
      Render_Test ("(a b (c))", Friday, "c");
   exception
      when Error : others => Test.Report_Exception (Error);
   end Test_Discrete;


   procedure Test_Integers (Report : in out NT.Reporter'Class) is
   begin
      Report.Section ("Integer templates");
      Natools.S_Expressions.Templates.Tests.Integers.All_Tests (Report);
      Report.End_Section;
   end Test_Integers;

end Natools.S_Expressions.Templates.Tests;

Modified tests/natools-s_expressions-templates-tests.ads from [a481e23742] to [346e2b4a31].

24
25
26
27
28
29
30

31
32
33
package Natools.S_Expressions.Templates.Tests is
   pragma Preelaborate;

   package NT renames Natools.Tests;

   procedure All_Tests (Report : in out NT.Reporter'Class);


   procedure Test_Integers (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Templates.Tests;







>



24
25
26
27
28
29
30
31
32
33
34
package Natools.S_Expressions.Templates.Tests is
   pragma Preelaborate;

   package NT renames Natools.Tests;

   procedure All_Tests (Report : in out NT.Reporter'Class);

   procedure Test_Discrete (Report : in out NT.Reporter'Class);
   procedure Test_Integers (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Templates.Tests;