Natools

Check-in [d01e18ba8f]
Login
Overview
Comment:constant_indefinite_ordered_map_tests: test the new Rank primitive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d01e18ba8fbdd95619216f54a748a4810bf783a6
User & Date: nat on 2017-06-21 19:51:32
Other Links: manifest | tags
Context
2017-06-22
21:10
cron-tests: add a test showing a bug in event list fusion check-in: 908d0e14c9 user: nat tags: trunk
2017-06-21
19:51
constant_indefinite_ordered_map_tests: test the new Rank primitive check-in: d01e18ba8f user: nat tags: trunk
2017-06-20
21:40
constant_indefinite_ordered_maps: add a Rank cursor primitive check-in: e76c115fef user: nat tags: trunk
Changes

Modified tests/natools-constant_indefinite_ordered_map_tests.adb from [d6079ac7f7] to [a608e64af8].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté                                        --
-- Copyright (c) 2014-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         --
108
109
110
111
112
113
114

115
116
117
118
119
120
121
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122







+







      Unsafe_Map_Roundtrip (Report);
      Ada_2012_Indexing (Report);
      Ada_2012_Iteration (Report);
      Ada_2012_Errors (Report);
      Range_Iterators (Report);
      Update_Constructors (Report);
      Update_Constructor_Exceptions (Report);
      Rank (Report);
   end All_Tests;



   ----------------------
   -- Individual Tests --
   ----------------------
876
877
878
879
880
881
882








































883
884
885
886
887
888
889
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930







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







         end loop;
         Test_Element (24);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Range_Iterators;


   procedure Rank (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Rank function");
   begin
      declare
         Map : constant Test_Maps.Updatable_Map := Sample_Map;

         procedure Test_Rank
           (Cursor : in Test_Maps.Cursor;
            Expected : in Ada.Containers.Count_Type;
            Name : in String);

         procedure Test_Rank
           (Cursor : in Test_Maps.Cursor;
            Expected : in Ada.Containers.Count_Type;
            Name : in String)
         is
            use type Ada.Containers.Count_Type;

            Actual : constant Ada.Containers.Count_Type
              := Test_Maps.Rank (Cursor);
         begin
            if Actual /= Expected then
               Test.Fail ("Expected rank"
                 & Ada.Containers.Count_Type'Image (Expected)
                 & " for " & Name & ", found"
                 & Ada.Containers.Count_Type'Image (Actual));
            end if;
         end Test_Rank;
      begin
         Test_Rank (Test_Maps.No_Element, 0, "No_Element");
         Test_Rank (Map.First, 1, "Map.First");
         Test_Rank (Map.Last, 20, "Map.Last");
         Test_Rank (Test_Maps.Next (Map.First), 2, "Next (Map.First)");
         Test_Rank (Test_Maps.Next (Map.Last), 0, "Next (Map.Last)");
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Rank;


   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 [f113882e14] to [173b001954].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté                                        --
-- Copyright (c) 2014-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         --
29
30
31
32
33
34
35

36
37
38
39
40
29
30
31
32
33
34
35
36
37
38
39
40
41







+





   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_Iterators (Report : in out NT.Reporter'Class);
   procedure Rank (Report : in out NT.Reporter'Class);
   procedure Unsafe_Map_Roundtrip (Report : in out NT.Reporter'Class);
   procedure Update_Constructors (Report : in out NT.Reporter'Class);
   procedure Update_Constructor_Exceptions (Report : in out NT.Reporter'Class);

end Natools.Constant_Indefinite_Ordered_Map_Tests;