Created
October 21, 2011 10:35
-
-
Save oenone/1303539 to your computer and use it in GitHub Desktop.
Unicode Test File for http://gynvael.coldwind.pl/download.php?f=str_to_int_unicode.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Author: Julian Leyh <julian@vgai.de> | |
-- Compile with: gnatmake -gnat05 main.adb | |
with Ada.Text_IO; | |
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; | |
with Ada.Wide_Wide_Characters.Handling; | |
with Ada.Wide_Wide_Text_IO; | |
procedure Main is | |
package Int_IO is new Ada.Wide_Wide_Text_IO.Integer_IO (Integer); | |
subtype Short_String is Wide_Wide_String (1 .. 1); | |
Test_Array : array (1 .. 420) of Short_String; | |
Conv_Okay : array (1 .. 420) of Boolean := (others => True); | |
Is_Okay : array (1 .. 420) of Boolean := (others => True); | |
procedure Test_Part (Part_Name : String; Start_Offset : Natural) is | |
begin | |
Ada.Text_IO.Put (" " & Part_Name & ": Conv "); | |
if Conv_Okay (Start_Offset + 1 .. Start_Offset + 10) = (1 .. 10 => True) then | |
Ada.Text_IO.Put ("ok"); | |
elsif Conv_Okay (Start_Offset + 1 .. Start_Offset + 10) = (1 .. 10 => False) then | |
Ada.Text_IO.Put ("fail"); | |
else | |
Ada.Text_IO.Put ("partly"); | |
end if; | |
Ada.Text_IO.Put (", Is_Digit "); | |
if Is_Okay (Start_Offset + 1 .. Start_Offset + 10) = (1 .. 10 => True) then | |
Ada.Text_IO.Put ("ok"); | |
elsif Is_Okay (Start_Offset + 1 .. Start_Offset + 10) = (1 .. 10 => False) then | |
Ada.Text_IO.Put ("fail"); | |
else | |
Ada.Text_IO.Put ("partly"); | |
end if; | |
Ada.Text_IO.New_Line; | |
end Test_Part; | |
Input_File : Ada.Text_IO.File_Type; | |
Last, Value : Integer; | |
begin | |
Ada.Text_IO.Put_Line ("Reading File..."); | |
Ada.Text_IO.Open (Input_File, Ada.Text_IO.In_File, "test_case_utf8.txt"); | |
for I in Test_Array'Range loop | |
declare | |
Utf_Line : constant Ada.Strings.UTF_Encoding.UTF_8_String := | |
Ada.Text_IO.Get_Line (Input_File); | |
Wide_Line : constant Wide_Wide_String := | |
Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode (Utf_Line); | |
begin | |
Test_Array (I) := Wide_Line (Wide_Line'First .. Wide_Line'First); | |
end; | |
end loop; | |
Ada.Text_IO.Close (Input_File); | |
Ada.Text_IO.Put_Line ("Testing Conversion..."); | |
for I in Test_Array'Range loop | |
begin | |
Int_IO.Get (From => Test_Array (I), | |
Item => Value, | |
Last => Last); | |
if Value /= (I - 1) mod 10 then | |
Ada.Text_IO.Put_Line (" Conversion Failed for" & Integer'Image (I)); | |
Conv_Okay (I) := False; | |
end if; | |
exception | |
when others => | |
Ada.Text_IO.Put_Line (" Conversion Failed for" & Integer'Image (I)); | |
Conv_Okay (I) := False; | |
end; | |
end loop; | |
Ada.Text_IO.Put_Line ("Testing Is_Digit..."); | |
for I in Test_Array'Range loop | |
if not Ada.Wide_Wide_Characters.Handling.Is_Digit (Test_Array (I) (1)) then | |
Ada.Text_IO.Put_Line (" Is_Digit Failed for" & Integer'Image (I)); | |
Is_Okay (I) := False; | |
end if; | |
end loop; | |
Ada.Text_IO.Put_Line ("Results:"); | |
Test_Part ("ASCII", 0); | |
Test_Part ("ARABIC-INDIC", 10); | |
Test_Part ("EXTENDED ARABIC-INDIC", 20); | |
Test_Part ("NKO", 30); | |
Test_Part ("DEVANAGARI", 40); | |
Test_Part ("BENGALI", 50); | |
Test_Part ("GURMUKHI", 60); | |
Test_Part ("GUJARATI", 70); | |
Test_Part ("ORIYA", 80); | |
Test_Part ("TAMIL", 90); | |
Test_Part ("TELUGU", 100); | |
Test_Part ("KANNADA", 110); | |
Test_Part ("MALAYALAM", 120); | |
Test_Part ("THAI", 130); | |
Test_Part ("LAO", 140); | |
Test_Part ("TIBETAN", 150); | |
Test_Part ("MYANMAR", 160); | |
Test_Part ("MYANMAR SHAN", 170); | |
Test_Part ("KHMER", 180); | |
Test_Part ("MONGOLIAN", 190); | |
Test_Part ("LIMBU", 200); | |
Test_Part ("NEW TAI LUE", 210); | |
Test_Part ("TAI THAM HORA", 220); | |
Test_Part ("TAI THAM THAM", 230); | |
Test_Part ("BALINESE", 240); | |
Test_Part ("SUNDANESE", 250); | |
Test_Part ("LEPCHA", 260); | |
Test_Part ("OL CHIKI", 270); | |
Test_Part ("VAI", 280); | |
Test_Part ("SAURASHTRA", 290); | |
Test_Part ("KAYAH LI", 300); | |
Test_Part ("JAVANESE", 310); | |
Test_Part ("CHAM", 320); | |
Test_Part ("MEETEI MAYEK", 330); | |
Test_Part ("FULLWIDTH", 340); | |
Test_Part ("OSMANYA", 350); | |
Test_Part ("BRAHMI", 360); | |
Test_Part ("MATHEMATICAL BOLD", 370); | |
Test_Part ("MATHEMATICAL DOUBLE-STRUCK", 380); | |
Test_Part ("MATHEMATICAL SANS-SERIF", 390); | |
Test_Part ("MATHEMATICAL SANS-SERIF BOLD", 400); | |
Test_Part ("MATHEMATICAL MONOSPACE", 410); | |
Ada.Text_IO.Put_Line ("Finished"); | |
end Main; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results compiling with GNAT GPL 2011: