Natools

Check-in [98083b9906]
Login
Overview
Comment:constant_indefinite_ordered_map_tests: add a fully-covering test of the new range iterator feature
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 98083b99061b0698aa1a40f547b0247d0ba7b2d8
User & Date: nat on 2014-12-15 22:40:27
Other Links: manifest | tags
Context
2015-01-14
20:55
time_keys: new package that provides short printable chronological keys check-in: 0ca258c8c8 user: nat tags: trunk
2014-12-15
22:40
constant_indefinite_ordered_map_tests: add a fully-covering test of the new range iterator feature check-in: 98083b9906 user: nat tags: trunk
2014-12-14
19:11
constant_indefinite_ordered_maps: add a reversible interator that operates on a sub-range of the map check-in: d7573547c0 user: nat tags: trunk
Changes

Modified tests/natools-constant_indefinite_ordered_map_tests.adb from [e3dd7affd1] to [dd94feabff].

105
106
107
108
109
110
111

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







+







      Empty_Map (Report);
      Iterations (Report);
      Map_Updates (Report);
      Unsafe_Map_Roundtrip (Report);
      Ada_2012_Indexing (Report);
      Ada_2012_Iteration (Report);
      Ada_2012_Errors (Report);
      Range_Iteratiors (Report);
   end All_Tests;



   ----------------------
   -- Individual Tests --
   ----------------------
782
783
784
785
786
787
788



























































































789
790
791
792
793
794
795
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
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887







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







            Test.Fail ("Moved orphaned cursor has lost its value");
         end if;
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Map_Updates;


   procedure Range_Iteratiors (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Map updates");
   begin
      declare
         Map : constant Test_Maps.Updatable_Map := Sample_Map;
         Expected, Direction : Integer;
         Abort_Loop : Boolean := False;

         procedure Test_Element (Element : in Integer);

         procedure Test_Element (Element : in Integer) is
         begin
            if Expected /= Element then
               Test.Fail ("Got element" & Integer'Image (Element)
                 & ", expected" & Integer'Image (Expected));
               Test.Info ("Current map: " & Image (Map));
               Abort_Loop := True;
            end if;

            Expected := Expected + Direction;
         end Test_Element;
      begin
         Direction := 1;
         Expected := 10;
         Abort_Loop := False;
         for Position in Map.Iterate loop
            Test_Element (Test_Maps.Element (Position));
            exit when Abort_Loop;
         end loop;

         Direction := 1;
         Expected := 15;
         Abort_Loop := False;
         for Position in Map.Iterate (Map.Find ("15"), Map.Find ("25")) loop
            Test_Element (Test_Maps.Element (Position));
            exit when Abort_Loop;
         end loop;
         Test_Element (26);

         Direction := -1;
         Expected := 23;
         Abort_Loop := False;
         for Position in reverse Map.Iterate (Map.Find ("13"), Map.Find ("23"))
         loop
            Test_Element (Test_Maps.Element (Position));
            exit when Abort_Loop;
         end loop;
         Test_Element (12);

         Direction := 1;
         Expected := 99;
         Abort_Loop := False;
         for Position in Map.Iterate (Map.Find ("17"), Map.Find ("16")) loop
            Test_Element (Test_Maps.Element (Position));
            exit when Abort_Loop;
         end loop;
         Test_Element (99);

         Direction := 1;
         Expected := 99;
         Abort_Loop := False;
         for Position in reverse Map.Iterate (Map.Find ("27"), Map.Find ("26"))
         loop
            Test_Element (Test_Maps.Element (Position));
            exit when Abort_Loop;
         end loop;
         Test_Element (99);

         Direction := 1;
         Expected := 10;
         Abort_Loop := False;
         for Position in Map.Iterate (Map.First, Map.Find ("20")) loop
            Test_Element (Test_Maps.Element (Position));
            exit when Abort_Loop;
         end loop;
         Test_Element (21);

         Direction := -1;
         Expected := 29;
         Abort_Loop := False;
         for Position in reverse Map.Iterate (Map.Find ("25"), Map.Last) loop
            Test_Element (Test_Maps.Element (Position));
            exit when Abort_Loop;
         end loop;
         Test_Element (24);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Range_Iteratiors;


   procedure Unsafe_Map_Roundtrip (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Constant_Map <-> Unsafe_Map roundtrip");
   begin
      declare
         use type Test_Maps.Unsafe_Maps.Map;

Modified tests/natools-constant_indefinite_ordered_map_tests.ads from [18ef90ce9e] to [4ff2666077].

28
29
30
31
32
33
34

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







+



   procedure Ada_2012_Iteration (Report : in out NT.Reporter'Class);
   procedure Consistency (Report : in out NT.Reporter'Class);
   procedure Cursor_Operations (Report : in out NT.Reporter'Class);
   procedure Direct_Access (Report : in out NT.Reporter'Class);
   procedure Empty_Map (Report : in out NT.Reporter'Class);
   procedure Iterations (Report : in out NT.Reporter'Class);
   procedure Map_Updates (Report : in out NT.Reporter'Class);
   procedure Range_Iteratiors (Report : in out NT.Reporter'Class);
   procedure Unsafe_Map_Roundtrip (Report : in out NT.Reporter'Class);

end Natools.Constant_Indefinite_Ordered_Map_Tests;