Natools

Check-in [5ac45318fd]
Login
Overview
Comment:string_slice_set_tests: check reduction operations
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5ac45318fd00f750bfb4f0ce388dea1f133d9051
User & Date: nat on 2013-10-27 15:49:11
Other Links: manifest | tags
Context
2013-10-28
19:01
string_slice_set_tests: check navigation beyond bounds check-in: 243b66af93 user: nat tags: trunk
2013-10-27
15:49
string_slice_set_tests: check reduction operations check-in: 5ac45318fd user: nat tags: trunk
2013-10-13
15:47
string_slice_set_tests: test slice-based interface check-in: 36dd585941 user: nat tags: trunk
Changes

Modified tests/natools-string_slice_set_tests.adb from [09428966e6] to [931b1d762f].

104
105
106
107
108
109
110

111
112
113
114
115
116
117
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118







+








   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Test_Conversions (Report);
      Test_Exceptions (Report);
      Test_Interval_Arithmetic (Report);
      Test_Navigation (Report);
      Test_Reductions (Report);
      Test_Slices (Report);
      Test_Tokenization (Report);
   end All_Tests;



   ----------------------
777
778
779
780
781
782
783


































































784
785
786
787
788
789
790
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857







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







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


   procedure Test_Reductions (Report : in out NT.Reporter'Class) is
      Name : constant String := "Slice set reductions";
      Reported : Boolean := False;
   begin
      declare
         use type Slice_Sets.Slice_Set;

         Set : Slice_Sets.Slice_Set := Slice_Sets.To_Slice_Set (Parent_String);
         Subset : Slice_Sets.Slice_Set;
         First : constant Positive := 21;
         Last : constant Positive := 50;
         Middle_First : constant Positive := 30;
         Middle_Last : constant Positive := 39;
         Expected_String : constant String
           := Parent_String (First .. Middle_First - 1)
            & Parent_String (Middle_Last + 1 .. Last);
      begin
         Set.Exclude_Slice (Middle_First, Middle_Last);
         Set.Restrict (First, Last);

         if Set.To_String /= Expected_String then
            Info_Fail (Report, Name, Reported,
              "Expected """ & Expected_String & '"');
            Dump (Report, Set);
         end if;

         Set.Restrict (First, First - 1);
         if Set.Is_Null or not Set.Is_Empty then
            Info_Fail (Report, Name, Reported, "Expected empty set");
            Dump (Report, Set);
         end if;

         Subset := Set.Subset (Parent_String'First, Parent_String'Last);
         if Subset.Is_Null or not Set.Is_Empty then
            Info_Fail (Report, Name, Reported, "Expected empty subset");
            Dump (Report, Subset);
         end if;

         Set.Add_Slice (First, Last);
         Set.Exclude_Slice (Middle_First, Middle_Last);

         Subset := Set.Subset (Parent_String'First, Last);
         if Subset /= Set then
            Info_Fail (Report, Name, Reported, "Expected equal subset");
            Dump (Report, Set);
            Dump (Report, Subset);
         end if;

         Subset := Set.Subset (First + 1, Middle_First - 2);
         if Subset.To_String
           /= Parent_String (First + 1 .. Middle_First - 2)
         then
            Info_Fail (Report, Name, Reported, "Expected """
              & Parent_String (First + 1 .. Middle_First - 2) & '"');
            Dump (Report, Subset);
         end if;
      end;

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


   procedure Test_Navigation (Report : in out NT.Reporter'Class) is
      Name : constant String := "External index navigation";
   begin
      declare
         Set : Slice_Sets.Slice_Set := Slice_Sets.To_Slice_Set (Parent_String);
         Middle_First : constant Positive := 20;

Modified tests/natools-string_slice_set_tests.ads from [4dcbf41014] to [ab0e95d479].

28
29
30
31
32
33
34

35
36
37
38
28
29
30
31
32
33
34
35
36
37
38
39







+





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

   procedure Test_Conversions (Report : in out NT.Reporter'Class);
   procedure Test_Exceptions (Report : in out NT.Reporter'Class);
   procedure Test_Interval_Arithmetic (Report : in out NT.Reporter'Class);
   procedure Test_Navigation (Report : in out NT.Reporter'Class);
   procedure Test_Reductions (Report : in out NT.Reporter'Class);
   procedure Test_Slices (Report : in out NT.Reporter'Class);
   procedure Test_Tokenization (Report : in out NT.Reporter'Class);

end Natools.String_Slice_Set_Tests;