Natools

Check-in [3f152ff81d]
Login
Overview
Comment:s_expressions-templates-tests-integers: test the new prefix and suffix features
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3f152ff81d6b58adb270f44072761faea5e3400a
User & Date: nat on 2014-09-28 14:25:53
Other Links: manifest | tags
Context
2014-09-29
21:50
s_expressions-templates-generic_integers: add width information to prefix and suffixes check-in: 3c1dba5e77 user: nat tags: trunk
2014-09-28
14:25
s_expressions-templates-tests-integers: test the new prefix and suffix features check-in: 3f152ff81d user: nat tags: trunk
2014-09-27
16:30
s_expressions-templates-generic_integers: change prefix and suffix syntax to make shared values clearer check-in: 0c604fe54e user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-templates-tests-integers.adb from [ce1e623a4b] to [c71a337dba].

88
89
90
91
92
93
94

95
96
97
98
99
100
101
      Explicit_Images (Report);
      Explicit_Sign (Report);
      Hexadecimal (Report);
      Overflow (Report);
      Parse_Errors (Report);
      Static_Hash_Map (Report);
      Explicit_Default_Format (Report);

   end All_Tests;


   -----------------------
   -- Inidividual Tests --
   -----------------------








>







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
      Explicit_Images (Report);
      Explicit_Sign (Report);
      Hexadecimal (Report);
      Overflow (Report);
      Parse_Errors (Report);
      Static_Hash_Map (Report);
      Explicit_Default_Format (Report);
      Prefix_And_Suffix (Report);
   end All_Tests;


   -----------------------
   -- Inidividual Tests --
   -----------------------

213
214
215
216
217
218
219












































































220
221
222
223
224
225
226
227
228
229
230
231
      Test_Render (Test, "(width)", 8, "8");
      Test_Render (Test, "(max-width)", 9, "9");
      Test_Render (Test, "(min-width)", 10, "10");
   exception
      when Error : others => Test.Report_Exception (Error);
   end Parse_Errors;














































































   procedure Static_Hash_Map (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Parse errors in template");
   begin
      if not Natools.Static_Maps.S_Expressions.Templates.Integers.T then
         Test.Fail;
      end if;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Static_Hash_Map;

end Natools.S_Expressions.Templates.Tests.Integers;







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












214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
      Test_Render (Test, "(width)", 8, "8");
      Test_Render (Test, "(max-width)", 9, "9");
      Test_Render (Test, "(min-width)", 10, "10");
   exception
      when Error : others => Test.Report_Exception (Error);
   end Parse_Errors;


   procedure Prefix_And_Suffix (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Parse errors in template");
      Ordinal : constant String
        := "(suffix 1:? (th (0 31)) (st 1 21 31) (nd 2 22) (rd 3 23) (0: 0))";
   begin
      declare
         Format : Templates.Integers.Format;
      begin
         Format.Set_Prefix ((0, 9), To_Atom ("a"));
         Format.Set_Prefix ((-99, -10), To_Atom ("b"));
         Format.Set_Prefix ((50, 99), To_Atom ("c"));
         Format.Set_Prefix (0, To_Atom ("d"));
         Format.Set_Prefix (-10, To_Atom ("e"));
         Format.Set_Prefix (5, To_Atom ("f"));
         Format.Set_Prefix ((7, 52), To_Atom ("g"));
         Format.Set_Prefix ((-52, -49), To_Atom ("h"));
         Format.Set_Prefix ((-100, -90), To_Atom ("i"));
         Format.Remove_Prefix (8);

         Test_Render (Test, Format, "", -196, "-196");
         Test_Render (Test, Format, "", -101, "-101");
         Test_Render (Test, Format, "", -100, "i-100");
         Test_Render (Test, Format, "", -90, "i-90");
         Test_Render (Test, Format, "", -89, "b-89");
         Test_Render (Test, Format, "", -53, "b-53");
         Test_Render (Test, Format, "", -52, "h-52");
         Test_Render (Test, Format, "", -49, "h-49");
         Test_Render (Test, Format, "", -48, "b-48");
         Test_Render (Test, Format, "", -11, "b-11");
         Test_Render (Test, Format, "", -10, "e-10");
         Test_Render (Test, Format, "", -9, "-9");
         Test_Render (Test, Format, "", -1, "-1");
         Test_Render (Test, Format, "", 0, "d0");
         Test_Render (Test, Format, "", 1, "a1");
         Test_Render (Test, Format, "", 4, "a4");
         Test_Render (Test, Format, "", 5, "f5");
         Test_Render (Test, Format, "", 6, "a6");
         Test_Render (Test, Format, "", 7, "g7");
         Test_Render (Test, Format, "", 8, "8");
         Test_Render (Test, Format, "", 9, "g9");
         Test_Render (Test, Format, "", 52, "g52");
         Test_Render (Test, Format, "", 53, "c53");
         Test_Render (Test, Format, "", 99, "c99");
         Test_Render (Test, Format, "", 100, "100");
         Test_Render (Test, Format, "", 192, "192");
      end;

      declare
         Format : Templates.Integers.Format;
      begin
         Format.Set_Suffix ((0, 10), To_Atom ("th"));
         Format.Set_Suffix (1, To_Atom ("st"));
         Format.Remove_Suffix (0);

         Test_Render (Test, Format, "", -1, "-1");
         Test_Render (Test, Format, "", 0, "0");
         Test_Render (Test, Format, "", 1, "1st");
         Test_Render (Test, Format, "", 4, "4th");
         Test_Render (Test, Format, "", 10, "10th");
      end;

      Test_Render (Test, Ordinal, -1, "-1?");
      Test_Render (Test, Ordinal, 0, "0");
      Test_Render (Test, Ordinal, 1, "1st");
      Test_Render (Test, Ordinal, 2, "2nd");
      Test_Render (Test, Ordinal, 3, "3rd");
      Test_Render (Test, Ordinal, 4, "4th");

      Test_Render (Test, "(prefix (a) (b invalid (9 5)))", 0, "0");
      Test_Render (Test, "(prefix (c (invalid 5) (-1 invalid)))", 0, "0");
      Test_Render (Test, "(prefix (d ((invalid) 5) (-1)) ())", 0, "0");
   exception
      when Error : others => Test.Report_Exception (Error);
   end Prefix_And_Suffix;


   procedure Static_Hash_Map (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Parse errors in template");
   begin
      if not Natools.Static_Maps.S_Expressions.Templates.Integers.T then
         Test.Fail;
      end if;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Static_Hash_Map;

end Natools.S_Expressions.Templates.Tests.Integers;

Modified tests/natools-s_expressions-templates-tests-integers.ads from [36b481a7a8] to [1b0e2b84dc].

28
29
30
31
32
33
34

35
36
37
   procedure Default_Format (Report : in out NT.Reporter'Class);
   procedure Explicit_Default_Format (Report : in out NT.Reporter'Class);
   procedure Explicit_Images (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;







>



28
29
30
31
32
33
34
35
36
37
38
   procedure Default_Format (Report : in out NT.Reporter'Class);
   procedure Explicit_Default_Format (Report : in out NT.Reporter'Class);
   procedure Explicit_Images (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 Prefix_And_Suffix (Report : in out NT.Reporter'Class);
   procedure Static_Hash_Map (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Templates.Tests.Integers;