Natools

Diff
Login

Differences From Artifact [bab2542056]:

To Artifact [396b4e2586]:


1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013-2017, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
76
77
78
79
80
81
82

83
84
85
86
87
88
89
      Test_Conversions (Report);
      Test_Extensions (Report);
      Test_Incoming_Range (Report);
      Test_Invalid_Extensions (Report);
      Test_Null_Slice (Report);
      Test_Outgoing_Range (Report);
      Test_Subslices (Report);

   end Slice_Tests;



   ----------------------
   -- Individual tests --
   ----------------------







>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
      Test_Conversions (Report);
      Test_Extensions (Report);
      Test_Incoming_Range (Report);
      Test_Invalid_Extensions (Report);
      Test_Null_Slice (Report);
      Test_Outgoing_Range (Report);
      Test_Subslices (Report);
      Test_New_Slice (Report);
   end Slice_Tests;



   ----------------------
   -- Individual tests --
   ----------------------
454
455
456
457
458
459
460






































































461
462
463
464
465
466
467
      if Result then
         Report.Item (Name, NT.Success);
      end if;
   exception
      when Error : others => Report.Report_Exception (Name, Error);
   end Test_Is_Subrange;








































































   procedure Test_Null_Slice (Report : in out NT.Reporter'Class) is
      procedure Check_Null (S : in String);

      Name : constant String := "Null slice to empty string";
      Result : Boolean := True;








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







455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
      if Result then
         Report.Item (Name, NT.Success);
      end if;
   exception
      when Error : others => Report.Report_Exception (Name, Error);
   end Test_Is_Subrange;


   procedure Test_New_Slice (Report : in out NT.Reporter'Class) is
      Name : constant String := "Callback-based constructor";
      First : constant Positive := 42;
      Last : constant Natural := First + Name'Length - 1;
      Result : Boolean := True;

      procedure Initialize (S : out String);

      procedure Initialize (S : out String) is
      begin
         S := Name;
      end Initialize;
   begin
      declare
         Slice : constant String_Slices.Slice
           := String_Slices.New_Slice (First, Last, Initialize'Access);
      begin
         if Slice.First /= First then
            if Result then
               Report.Item (Name, NT.Fail);
            end if;

            Report.Info ("Incorrect value"
              & Integer'Image (Slice.First) & " for Slice.First, expected"
              & Integer'Image (First));
            Result := False;
         end if;

         if Slice.Last /= Last then
            if Result then
               Report.Item (Name, NT.Fail);
            end if;

            Report.Info ("Incorrect value"
              & Integer'Image (Slice.Last) & " for Slice.Last, expected"
              & Integer'Image (Last));
            Result := False;
         end if;

         if Slice.Length /= Name'Length then
            if Result then
               Report.Item (Name, NT.Fail);
            end if;

            Report.Info ("Incorrect value"
              & Integer'Image (Slice.Length) & " for Slice.Length, expected"
              & Integer'Image (Name'Length));
            Result := False;
         end if;

         if Slice.To_String /= Name then
            if Result then
               Report.Item (Name, NT.Fail);
            end if;

            Report.Info ("Incorrect string """
              & Integer'Image (Slice.Length) & """ in Slice, expected """
              & Name & '"');
            Result := False;
         end if;
      end;

      if Result then
         Report.Item (Name, NT.Success);
      end if;
   exception
      when Error : others => Report.Report_Exception (Name, Error);
   end Test_New_Slice;


   procedure Test_Null_Slice (Report : in out NT.Reporter'Class) is
      procedure Check_Null (S : in String);

      Name : constant String := "Null slice to empty string";
      Result : Boolean := True;