summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compare.adb45
-rw-r--r--test/dirlist.adb93
2 files changed, 138 insertions, 0 deletions
diff --git a/test/compare.adb b/test/compare.adb
new file mode 100644
index 0000000..2273414
--- /dev/null
+++ b/test/compare.adb
@@ -0,0 +1,45 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Released into the public domain
+
+
+with
+
+ Ada.Text_IO,
+ FLTK.Filenames;
+
+
+procedure Compare is
+
+ package TIO renames Ada.Text_IO;
+ package FFN renames FLTK.Filenames;
+
+ Aardvark : String := "aardvark";
+ Zebra : String := "Zebra";
+ Two : String := "item_2";
+ Ten : String := "item_10";
+ Cap_Ten : String := "Item_10";
+
+begin
+
+ TIO.Put_Line ("Alphabetic comparison of " & Aardvark & " and " & Zebra & ": " &
+ FFN.Comparison'Image (FFN.Alpha_Sort (Aardvark, Zebra)));
+ TIO.Put_Line ("Case insensitive comparison of " & Aardvark & " and " & Zebra & ": " &
+ FFN.Comparison'Image (FFN.Case_Alpha_Sort (Aardvark, Zebra)));
+ TIO.New_Line;
+
+ TIO.Put_Line ("Alphabetic comparison of " & Two & " and " & Ten & ": " &
+ FFN.Comparison'Image (FFN.Alpha_Sort (Two, Ten)));
+ TIO.Put_Line ("Numeric comparison of " & Two & " and " & Ten & ": " &
+ FFN.Comparison'Image (FFN.Numeric_Sort (Two, Ten)));
+ TIO.New_Line;
+
+ TIO.Put_Line ("Numeric comparison of " & Two & " and " & Cap_Ten & ": " &
+ FFN.Comparison'Image (FFN.Numeric_Sort (Two, Cap_Ten)));
+ TIO.Put_Line ("Case insensitive comparison of " & Two & " and " & Cap_Ten & ": " &
+ FFN.Comparison'Image (FFN.Case_Numeric_Sort (Two, Cap_Ten)));
+
+end Compare;
+
+
diff --git a/test/dirlist.adb b/test/dirlist.adb
new file mode 100644
index 0000000..1a07515
--- /dev/null
+++ b/test/dirlist.adb
@@ -0,0 +1,93 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Released into the public domain
+
+
+with
+
+ Ada.Characters.Latin_1,
+ Ada.Command_Line,
+ Ada.Text_IO,
+ FLTK.Filenames;
+
+
+procedure Dirlist is
+
+ package Latin renames Ada.Characters.Latin_1;
+ package ACom renames Ada.Command_Line;
+ package TIO renames Ada.Text_IO;
+ package Fil renames FLTK.Filenames;
+
+begin
+
+ TIO.Put_Line ("Test program for FLTK directory listing function.");
+ TIO.New_Line;
+ TIO.Put ("Input: ");
+ for Index in 1 .. ACom.Argument_Count loop
+ TIO.Put (ACom.Argument (Index));
+ exit when Index = ACom.Argument_Count;
+ TIO.Put (" ");
+ end loop;
+ TIO.New_Line;
+ TIO.New_Line;
+
+ if ACom.Argument_Count /= 1 then
+ TIO.Put_Line ("Error: Need exactly one argument to denote a directory to list.");
+ ACom.Set_Exit_Status (ACom.Failure);
+ return;
+ end if;
+
+ declare
+ Name : Fil.Path_String := Fil.Expand (ACom.Argument (1));
+ begin
+ if not Fil.Is_Directory (Name) then
+ TIO.Put_Line ("Error: " & Name & " is not a valid directory.");
+ ACom.Set_Exit_Status (ACom.Failure);
+ return;
+ end if;
+
+ declare
+ The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Alpha_Sort'Access);
+ begin
+ TIO.Put_Line ("Alphabetical Sort:");
+ for Index in 1 .. The_List.Length loop
+ TIO.Put_Line (Latin.HT & The_List.Item (Index));
+ end loop;
+ TIO.New_Line;
+ end;
+
+ declare
+ The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Case_Alpha_Sort'Access);
+ begin
+ TIO.Put_Line ("Case Insensitive Alphabetical Sort:");
+ for Index in 1 .. The_List.Length loop
+ TIO.Put_Line (Latin.HT & The_List.Item (Index));
+ end loop;
+ TIO.New_Line;
+ end;
+
+ declare
+ The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Numeric_Sort'Access);
+ begin
+ TIO.Put_Line ("Numeric Sort:");
+ for Index in 1 .. The_List.Length loop
+ TIO.Put_Line (Latin.HT & The_List.Item (Index));
+ end loop;
+ TIO.New_Line;
+ end;
+
+ declare
+ The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Case_Numeric_Sort'Access);
+ begin
+ TIO.Put_Line ("Case Insensitive Numeric Sort:");
+ for Index in 1 .. The_List.Length loop
+ TIO.Put_Line (Latin.HT & The_List.Item (Index));
+ end loop;
+ TIO.New_Line;
+ end;
+ end;
+
+end Dirlist;
+
+