Natools

Diff
Login

Differences From Artifact [8533326941]:

To Artifact [71375b159f]:


63
64
65
66
67
68
69
70



71
72
73
74



75
76
77
78
79
80
81
82
83
84
85
86
87


88
89
90
91
92
93
94
63
64
65
66
67
68
69

70
71
72
73
74
75

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100







-
+
+
+



-
+
+
+













+
+








   type Flag_Argument_Array is array (Option_Id) of US.Unbounded_String;

   Separator : constant Character := ';';

   package Getopt is new Natools.Getopt_Long (Option_Id);

   function Getopt_Config return Getopt.Configuration;
   function Getopt_Config
     (Posixly_Correct, Long_Only : Boolean)
      return Getopt.Configuration;
      --  Create the Getopt.Configuration object used for these tests.


   function Getopt_Config return Getopt.Configuration is
   function Getopt_Config
     (Posixly_Correct, Long_Only : Boolean)
      return Getopt.Configuration is
   begin
      return OD : Getopt.Configuration do
         OD.Add_Option ('a', Getopt.No_Argument, Short_No_Arg);
         OD.Add_Option ('q', Getopt.No_Argument, Short_No_Arg_2);
         OD.Add_Option ('f', Getopt.Required_Argument, Short_Arg);
         OD.Add_Option ('v', Getopt.Optional_Argument, Short_Opt_Arg);
         OD.Add_Option ("aq", Getopt.No_Argument, Long_Ambiguous);
         OD.Add_Option ("aquatic", Getopt.No_Argument, Long_No_Arg);
         OD.Add_Option ("color", Getopt.Optional_Argument, Long_Opt_Arg);
         OD.Add_Option ("input", Getopt.Required_Argument, Long_Arg);
         OD.Add_Option ("execute", 'e', Getopt.Required_Argument, Mixed_Arg);
         OD.Add_Option ("ignore-case", 'i', Getopt.No_Argument, Mixed_No_Arg);
         OD.Add_Option ("write", 'w', Getopt.Optional_Argument, Mixed_Opt_Arg);
         OD.Posixly_Correct (Posixly_Correct);
         OD.Use_Long_Only (Long_Only);
      end return;
   end Getopt_Config;



   -------------------
   -- Test Handlers --
284
285
286
287
288
289
290
291


292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
290
291
292
293
294
295
296

297
298
299
300
301
302
303
304


305
306
307
308
309
310
311







-
+
+






-
-







      Expected_Seen : Flag_Seen_Array;
      Expected_Argument : Flag_Argument_Array;
      Expected_Error : String_Vectors.Vector := String_Vectors.Empty_Vector;
      Posixly_Correct : Boolean := True;
      Long_Only : Boolean := False)
   is
      use type String_Vectors.Vector;
      Config : constant Getopt.Configuration := Getopt_Config;
      Config : constant Getopt.Configuration
        := Getopt_Config (Posixly_Correct, Long_Only);
      Handler : Handlers.Basic;
   begin
      begin
         Getopt.Process
           (Config             => Config,
            Handler            => Handler,
            Posixly_Correct    => Posixly_Correct,
            Long_Only          => Long_Only,
            Argument_Count     => Argument_Count'Access,
            Argument           => Argument'Access);
      exception
         when Error : Getopt.Option_Error =>
            Handler.Flag_Error.Append
              (Ada.Exceptions.Exception_Message (Error));
      end;
385
386
387
388
389
390
391
392

393
394
395
396
397
398
399
390
391
392
393
394
395
396

397
398
399
400
401
402
403
404







-
+







      procedure Local_Test
        (Name : String;
         Expected_Seen : Flag_Seen_Array;
         Expected_Argument : Flag_Argument_Array;
         Expected_Count : Handlers.Error_Count)
      is
         use type Handlers.Error_Count;
         Config : constant Getopt.Configuration := Getopt_Config;
         Config : constant Getopt.Configuration := Getopt_Config (True, False);
         Handler : Handlers.Recovering;
      begin
         Getopt.Process
           (Config         => Config,
            Handler        => Handler,
            Argument_Count => Argument_Count'Access,
            Argument       => Argument'Access);