Natools

Check-in [3604ae2791]
Login
Overview
Comment:s_expressions-printers-pretty-config-tests: add a test for the serializer
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3604ae27912210c15454def5fc76d58c9e385d9c
User & Date: nat on 2014-03-21 20:15:04
Other Links: manifest | tags
Context
2014-03-22
20:58
s_expressions-atom_buffers: new procedure to reverse the contents of an atom buffer check-in: 20f1537eb4 user: nat tags: trunk
2014-03-21
20:15
s_expressions-printers-pretty-config-tests: add a test for the serializer check-in: 3604ae2791 user: nat tags: trunk
2014-03-20
21:14
s_expressions-printers-pretty-config: add a procedure to serialize pretty printer configuration check-in: ab7de61c81 user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-printers-pretty-config-tests.adb from [54e51663e5] to [d415ce2c36].

192
193
194
195
196
197
198

199
200
201
202
203
204
205
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206







+







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

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



   ----------------------
   -- Individual Tests --
   ----------------------
281
282
283
284
285
286
287






































































































































































288
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

         Update (Param, Subparser);
         Check_Param (Test, Param, Expected, "In fifth expression:");
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Read_Test;


   procedure Write_Test (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Write parameters into S-expression");

      procedure Testcase
        (Title : in String;
         Param : in Parameters;
         Expr : in String);

      procedure Testcase
        (Title : in String;
         Param : in Parameters;
         Expr : in String)
      is
         Buffer : aliased Test_Tools.Memory_Stream;
         Output : Printers.Canonical (Buffer'Access);
         Parser : aliased Parsers.Parser;
         Subparser : Parsers.Subparser (Parser'Access, Buffer'Access);
         Reread : Parameters := Pretty.Canonical;
      begin
         Buffer.Set_Expected (To_Atom (Expr));
         Print (Output, Param);
         Subparser.Next;
         Update (Reread, Subparser);
         Check_Param (Test, Reread, Param, Title);
         Buffer.Check_Stream (Test);
      end Testcase;
   begin
      Testcase ("First case:",
        (Width => 80,
         Newline_At => (others => (others => True)),
         Space_At => (others => (others => True)),
         Tab_Stop => 4,
         Indentation => 1,
         Indent => Tabs,
         Quoted => Single_Line,
         Token => Standard_Token,
         Hex_Casing => Encodings.Lower,
         Quoted_Escape => Hex_Escape,
         Char_Encoding => UTF_8,
         Fallback => Hexadecimal,
         Newline => CR_LF),
         "(7:newline5:cr-lf3:all)(5:space3:all)(8:tab-stop1:4)(5:width2:80)"
         & "(11:indentation1:13:tab)25:single-line-quoted-string"
         & "(6:escape11:hexadecimal)(5:token8:standard)5:utf-8"
         & "10:lower-case11:hexadecimal");

      Testcase ("Second case:",
        (Width => 0,
         Newline_At => (others => (Opening => True, others => False)),
         Space_At => (others => (Atom_Data => True, others => False)),
         Tab_Stop => 4,
         Indentation => 1,
         Indent => Spaces,
         Quoted => No_Quoted,
         Token => No_Token,
         Hex_Casing => Encodings.Upper,
         Quoted_Escape => Octal_Escape,
         Char_Encoding => ASCII,
         Fallback => Verbatim,
         Newline => LF),
         "(7:newline2:lf4:none9:open-open9:atom-open10:close-open)"
         & "(5:space4:none9:open-atom9:atom-atom10:close-atom)"
         & "(8:tab-stop1:4)"
         & "8:no-width(11:indentation1:15:space)16:no-quoted-string"
         & "(6:escape5:octal)(5:token5:never)5:ascii10:upper-case"
         & "8:verbatim");

      Testcase ("Third case:",
        (Width => 0,
         Newline_At => (others => (others => False)),
         Space_At => (others => (others => False)),
         Tab_Stop => 8,
         Indentation => 1,
         Indent => Tabs_And_Spaces,
         Quoted => When_Shorter,
         Token => Extended_Token,
         Hex_Casing => Encodings.Lower,
         Quoted_Escape => Octal_Escape,
         Char_Encoding => Latin,
         Fallback => Base64,
         Newline => CR),
         "(7:newline2:cr4:none)(5:space4:none)(8:tab-stop1:8)8:no-width"
         & "(11:indentation1:112:tabbed-space)26:quoted-string-when-shorter"
         & "(6:escape5:octal)(5:token8:extended)7:latin-1"
         & "10:lower-case7:base-64");

      Testcase ("Fourth case:",
        (Width => 0,
         Newline_At => (others => (others => True)),
         Space_At => (others => (others => True)),
         Tab_Stop => 8,
         Indentation => 3,
         Indent => Spaces,
         Quoted => No_Quoted,
         Token => No_Token,
         Hex_Casing => Encodings.Lower,
         Quoted_Escape => Octal_Escape,
         Char_Encoding => ASCII,
         Fallback => Base64,
         Newline => LF_CR),
         "(7:newline5:lf-cr3:all)(5:space3:all)(8:tab-stop1:8)8:no-width"
         & "(11:indentation1:36:spaces)16:no-quoted-string"
         & "(6:escape5:octal)(5:token5:never)5:ascii"
         & "10:lower-case7:base-64");

      Testcase ("Fifth case:",
        (Width => 0,
         Newline_At => (others => (others => True)),
         Space_At => (others => (others => True)),
         Tab_Stop => 8,
         Indentation => 2,
         Indent => Tabs,
         Quoted => No_Quoted,
         Token => No_Token,
         Hex_Casing => Encodings.Lower,
         Quoted_Escape => Octal_Escape,
         Char_Encoding => ASCII,
         Fallback => Base64,
         Newline => LF),
         "(7:newline2:lf3:all)(5:space3:all)(8:tab-stop1:8)8:no-width"
         & "(11:indentation1:24:tabs)16:no-quoted-string"
         & "(6:escape5:octal)(5:token5:never)5:ascii"
         & "10:lower-case7:base-64");

      Testcase ("Sixth case:",
        (Width => 0,
         Newline_At => (others => (others => True)),
         Space_At => (others => (others => True)),
         Tab_Stop => 8,
         Indentation => 4,
         Indent => Tabs_And_Spaces,
         Quoted => No_Quoted,
         Token => No_Token,
         Hex_Casing => Encodings.Lower,
         Quoted_Escape => Octal_Escape,
         Char_Encoding => ASCII,
         Fallback => Base64,
         Newline => LF),
         "(7:newline2:lf3:all)(5:space3:all)(8:tab-stop1:8)8:no-width"
         & "(11:indentation1:413:tabbed-spaces)16:no-quoted-string"
         & "(6:escape5:octal)(5:token5:never)5:ascii"
         & "10:lower-case7:base-64");

      Testcase ("Seventh case:",
        (Width => 0,
         Newline_At => (others => (others => True)),
         Space_At => (others => (others => True)),
         Tab_Stop => 8,
         Indentation => 0,
         Indent => Spaces,
         Quoted => No_Quoted,
         Token => No_Token,
         Hex_Casing => Encodings.Lower,
         Quoted_Escape => Octal_Escape,
         Char_Encoding => ASCII,
         Fallback => Base64,
         Newline => LF),
         "(7:newline2:lf3:all)(5:space3:all)(8:tab-stop1:8)8:no-width"
         & "14:no-indentation16:no-quoted-string"
         & "(6:escape5:octal)(5:token5:never)5:ascii"
         & "10:lower-case7:base-64");
   exception
      when Error : others => Test.Report_Exception (Error);
   end Write_Test;

end Natools.S_Expressions.Printers.Pretty.Config.Tests;

Modified tests/natools-s_expressions-printers-pretty-config-tests.ads from [5723f46ff3] to [b41b60ecf9].

26
27
28
29
30
31
32

33
34
26
27
28
29
30
31
32
33
34
35







+


   pragma Preelaborate (Tests);

   package NT renames Natools.Tests;

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

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

end Natools.S_Expressions.Printers.Pretty.Config.Tests;