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;
|