stephes_ada_library_3.7.3_08b48307/test/test-config_files-bad_file_name.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--  Abstract :
--
--  See spec
--
--  Copyright (C) 2003, 2004, 2009, 2015 Stephen Leake.  All Rights Reserved.
--
--  This program is free software; you can redistribute it and/or
--  modify it under terms of the GNU General Public License as
--  published by the Free Software Foundation; either version 3, or (at
--  your option) any later version. This program is distributed in the
--  hope that it will be useful, but WITHOUT ANY WARRANTY; without even
--  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
--  PURPOSE. See the GNU General Public License for more details. You
--  should have received a copy of the GNU General Public License
--  distributed with this program; see file COPYING. If not, write to
--  the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
--  MA 02111-1307, USA.

pragma License (GPL);

with Ada.IO_Exceptions;
with AUnit.Assertions;
with SAL.Config_Files; use SAL.Config_Files;
package body Test.Config_Files.Bad_File_Name is

   ----------
   --  Local subprogram declarations

   procedure Test_Open (T : in out AUnit.Test_Cases.Test_Case'Class);

   ----------
   --  Subprogram bodies (alphabetical order)

   overriding function Name (T : Test_Case) return AUnit.Message_String
   is
      pragma Unreferenced (T);
   begin
      return new String'("Bad file name tests");
   end Name;

   overriding procedure Register_Tests (T : in out Test_Case)
   is
      use AUnit.Test_Cases.Registration;
   begin
      Register_Routine (T, Test_Open'Access, "Test_Open");
   end Register_Tests;

   procedure Test_Open (T : in out AUnit.Test_Cases.Test_Case'Class)
   is
      pragma Unreferenced (T);
      Bad_File_Name : constant String := "/bad:/for Windows";

      Config : Configuration_Type;

      Name_Error_Raised : Boolean := False;
   begin

      begin
         Open (Config, Bad_File_Name, Missing_File => Ignore, Read_Only => False);
         Close (Config);
      exception
      when Ada.IO_Exceptions.Name_Error =>
         Name_Error_Raised := True;
      end;

      AUnit.Assertions.Assert (Name_Error_Raised, "did not raise Name_Error");

   end Test_Open;

end Test.Config_Files.Bad_File_Name;