Natools

Check-in [20f11298fe]
Login
Overview
Comment:string_slice_set_tests: extra tests on slice iterators
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 20f11298fe2b8602b29bd039dee843ccdce274a0
User & Date: nat on 2013-10-30 21:26:55
Other Links: manifest | tags
Context
2013-11-01
13:37
string_slice_set_tests: test Add_Slice with empty range check-in: 127bb5a0ae user: nat tags: trunk
2013-10-30
21:26
string_slice_set_tests: extra tests on slice iterators check-in: 20f11298fe user: nat tags: trunk
2013-10-29
22:51
string_slice_set_tests: check positive Find_Slice check-in: 98263a1ce0 user: nat tags: trunk
Changes

Modified tests/natools-string_slice_set_tests.adb from [43fcc60717] to [25da54231a].

1070
1071
1072
1073
1074
1075
1076
























1077
1078










































1079
1080
1081
1082
1083
1084
         elsif R /= (First => 27, Length => 3) then
            Report.Item (Name, NT.Fail);
            Report.Info ("Unexpected ""fox"" slice found at "
              & String_Slices.Image (R));
            Dump (Report, Set);
            return;
         end if;
























      end;











































      Report.Item (Name, NT.Success);
   exception
      when Error : others => Report.Report_Exception (Name, Error);
   end Test_Tokenization;

end Natools.String_Slice_Set_Tests;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

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






1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
         elsif R /= (First => 27, Length => 3) then
            Report.Item (Name, NT.Fail);
            Report.Info ("Unexpected ""fox"" slice found at "
              & String_Slices.Image (R));
            Dump (Report, Set);
            return;
         end if;

         declare
            procedure Count_Word_Length (S : in String_Slices.Slice);

            Word_Length : array (1 .. 5) of Natural := (others => 0);

            procedure Count_Word_Length (S : in String_Slices.Slice) is
            begin
               Word_Length (S.Length) := Word_Length (S.Length) + 1;
            end Count_Word_Length;
         begin
            Set.Query_Slices (Count_Word_Length'Access);

            if Word_Length /= (0, 0, 3, 3, 3) then
               Report.Item (Name, NT.Fail);
               Report.Info ("Unexpected word lengths:"
                 & Integer'Image (Word_Length (1))
                 & Integer'Image (Word_Length (2))
                 & Integer'Image (Word_Length (3))
                 & Integer'Image (Word_Length (4))
                 & Integer'Image (Word_Length (5)));
               Dump (Report, Set);
               return;
            end if;
         end;

         declare
            function Kill_Three_Letters (S : String)
              return String_Slices.String_Range;

            function Kill_Three_Letters (S : String)
              return String_Slices.String_Range is
            begin
               if S'Length = 3 then
                  return (S'First, 0);
               else
                  return (S'First, S'Length);
               end if;
            end Kill_Three_Letters;
         begin
            Set.Trim_Slices (Kill_Three_Letters'Access);

            if Set.To_String /= "quickbrownjumpsoverlazydog." then
               Report.Item (Name, NT.Fail);
               Report.Info ("Expected ""quickbrownjumpsoverlazydog.""");
               Dump (Report, Set);
               return;
            end if;
         end;

         declare
            use type Slice_Sets.Slice_Set;

            Derived : Slice_Sets.Slice_Set := Set;
         begin
            Derived.Cut_Before (21);
            Derived.Cut_Before (31);

            if Derived /= Set then
               Report.Item (Name, NT.Fail);
               Report.Info ("Unexpected side effect of Cut_Before");
               Dump (Report, Set);
               Dump (Report, Derived);
               return;
            end if;
         end;
      end;

      Report.Item (Name, NT.Success);
   exception
      when Error : others => Report.Report_Exception (Name, Error);
   end Test_Tokenization;

end Natools.String_Slice_Set_Tests;