vss_24.0.0_b4d0be7c/testsuite/text/test_string_casing_w3c_i18n.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
--
--  Copyright (C) 2021, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--

with Ada.Command_Line;
with Ada.Wide_Wide_Text_IO;

with VSS.Strings;

with Test_Support;

procedure Test_String_Casing_W3C_I18N is
   use type VSS.Strings.Virtual_String;

   File      : Ada.Wide_Wide_Text_IO.File_Type;
   Line      : Wide_Wide_String (1 .. 1024);
   Last      : Natural;
   Lowercase : Boolean;
   Source    : VSS.Strings.Virtual_String;
   Expected  : VSS.Strings.Virtual_String;

begin
   Ada.Wide_Wide_Text_IO.Open
     (File,
      Ada.Wide_Wide_Text_IO.In_File,
      Ada.Command_Line.Argument (1),
      "wcem=8");

   --  Skip name of the test

   Ada.Wide_Wide_Text_IO.Skip_Line (File);

   --  Read case conversion

   Ada.Wide_Wide_Text_IO.Get_Line (File, Line, Last);

   if Line (Line'First .. Last) = "lowercase" then
      Lowercase := True;

   elsif Line (Line'First .. Last) = "uppercase" then
      Lowercase := False;

   else
      raise Program_Error;
   end if;

   --  Read source string

   Ada.Wide_Wide_Text_IO.Get_Line (File, Line, Last);
   Source := VSS.Strings.To_Virtual_String (Line (Line'First .. Last));
   Test_Support.Assert (not Source.Is_Empty);

   --  Read expected string

   Ada.Wide_Wide_Text_IO.Get_Line (File, Line, Last);
   Expected := VSS.Strings.To_Virtual_String (Line (Line'First .. Last));
   Test_Support.Assert (not Expected.Is_Empty);

   Ada.Wide_Wide_Text_IO.Close (File);

   if Lowercase then
      Test_Support.Assert (Source.To_Lowercase = Expected);

   else
      Test_Support.Assert (Source.To_Uppercase = Expected);
   end if;
end Test_String_Casing_W3C_I18N;