diff options
author | Jed Barber <jjbarber@y7mail.com> | 2020-05-24 19:07:23 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2020-05-24 19:07:23 +1000 |
commit | 731e861f233ab90078c00b3dad5ace4eaed45e95 (patch) | |
tree | 173ac51104a31864a073e6c5c140853aee1ed80e | |
parent | 94609aeabcd441caa7c9d41f54166b3f3ede1442 (diff) |
Revamped tests to use the basic-unit-test project
-rw-r--r-- | test/rat_tests-errors.adb (renamed from test/ratnest-tests-errors.adb) | 14 | ||||
-rw-r--r-- | test/rat_tests-errors.ads | 32 | ||||
-rw-r--r-- | test/rat_tests-lexer.adb (renamed from test/ratnest-tests-lexer.adb) | 14 | ||||
-rw-r--r-- | test/rat_tests-lexer.ads | 81 | ||||
-rw-r--r-- | test/rat_tests-tokens.adb (renamed from test/ratnest-tests-tokens.adb) | 9 | ||||
-rw-r--r-- | test/rat_tests-tokens.ads | 22 | ||||
-rw-r--r-- | test/rat_tests-util.adb (renamed from test/ratnest-tests-util.adb) | 11 | ||||
-rw-r--r-- | test/rat_tests-util.ads | 48 | ||||
-rw-r--r-- | test/rat_tests.ads | 22 | ||||
-rw-r--r-- | test/ratnest-tests-graphs.adb | 140 | ||||
-rw-r--r-- | test/ratnest-tests.adb | 32 | ||||
-rw-r--r-- | test/ratnest-tests.ads | 186 | ||||
-rw-r--r-- | test/ratnest.adb | 34 | ||||
-rw-r--r-- | test/ratnest.ads | 47 | ||||
-rw-r--r-- | test/test_main.adb | 59 | ||||
-rw-r--r-- | tests.gpr | 4 |
16 files changed, 287 insertions, 468 deletions
diff --git a/test/ratnest-tests-errors.adb b/test/rat_tests-errors.adb index 136f6c9..75d2c34 100644 --- a/test/ratnest-tests-errors.adb +++ b/test/rat_tests-errors.adb @@ -1,7 +1,15 @@ -separate (Ratnest.Tests) -package body Errors is +with Packrat; + + +package body Rat_Tests.Errors is + + + package PE renames Packrat.Errors; + + + function Valid_Message_Check @@ -156,6 +164,6 @@ package body Errors is end Decode_Check; -end Errors; +end Rat_Tests.Errors; diff --git a/test/rat_tests-errors.ads b/test/rat_tests-errors.ads new file mode 100644 index 0000000..adbdded --- /dev/null +++ b/test/rat_tests-errors.ads @@ -0,0 +1,32 @@ + + +with Unit_Tests; +use Unit_Tests; + + +package Rat_Tests.Errors is + + + function Valid_Message_Check return Test_Result; + function Valid_Identifier_Check return Test_Result; + function Join_Check return Test_Result; + function Encode_1_Check return Test_Result; + function Encode_2_Check return Test_Result; + function Encode_3_Check return Test_Result; + function Encode_4_Check return Test_Result; + function Decode_Check return Test_Result; + + Tests : Test_Array := + ((+"Valid_Message", Valid_Message_Check'Access), + (+"Valid_Identifier", Valid_Identifier_Check'Access), + (+"Join", Join_Check'Access), + (+"Encode_1", Encode_1_Check'Access), + (+"Encode_2", Encode_2_Check'Access), + (+"Encode_3", Encode_3_Check'Access), + (+"Encode_4", Encode_4_Check'Access), + (+"Decode", Decode_Check'Access)); + + +end Rat_Tests.Errors; + + diff --git a/test/ratnest-tests-lexer.adb b/test/rat_tests-lexer.adb index dbdf5d6..702de18 100644 --- a/test/ratnest-tests-lexer.adb +++ b/test/rat_tests-lexer.adb @@ -1,11 +1,15 @@ -with Ada.Text_IO; -use Ada.Text_IO; +with + Packrat.Lexer.Debug, + Packrat.Util; -separate (Ratnest.Tests) -package body Lexer is + +package body Rat_Tests.Lexer is + + + package PU renames Packrat.Util; type My_Labels is (One, Two, Three); @@ -1011,6 +1015,6 @@ package body Lexer is end Scan_Set_With_Error_Check; -end Lexer; +end Rat_Tests.Lexer; diff --git a/test/rat_tests-lexer.ads b/test/rat_tests-lexer.ads new file mode 100644 index 0000000..bc3045c --- /dev/null +++ b/test/rat_tests-lexer.ads @@ -0,0 +1,81 @@ + + +with Unit_Tests; +use Unit_Tests; + + +package Rat_Tests.Lexer is + + + function Join_Check return Test_Result; + function Equals_Check return Test_Result; + + function Sequence_Check return Test_Result; + function Count_Check return Test_Result; + function Many_Check return Test_Result; + function Many_Until_Check return Test_Result; + + function Satisfy_Check return Test_Result; + function Satisfy_With_Check return Test_Result; + function Match_Check return Test_Result; + function Match_With_Check return Test_Result; + function Multimatch_Check return Test_Result; + function Take_Check return Test_Result; + function Take_While_Check return Test_Result; + function Take_Until_Check return Test_Result; + + function Line_End_Check return Test_Result; + function Input_End_Check return Test_Result; + + Combinator_Tests : Test_Array := + ((+"Join", Join_Check'Access), + (+"Equals", Equals_Check'Access), + (+"Sequence", Sequence_Check'Access), + (+"Count", Count_Check'Access), + (+"Many", Many_Check'Access), + (+"Many_Until", Many_Until_Check'Access), + (+"Satisfy", Satisfy_Check'Access), + (+"Satisfy With", Satisfy_With_Check'Access), + (+"Match", Match_Check'Access), + (+"Match With", Match_With_Check'Access), + (+"Multimatch", Multimatch_Check'Access), + (+"Take", Take_Check'Access), + (+"Take While", Take_While_Check'Access), + (+"Take Until", Take_Until_Check'Access), + (+"Line End", Line_End_Check'Access), + (+"Input_End", Input_End_Check'Access)); + + + function Stamp_Check return Test_Result; + function Ignore_Check return Test_Result; + + function Scan_Check return Test_Result; + function Scan_Only_Check return Test_Result; + function Scan_With_Check return Test_Result; + function Scan_Set_Check return Test_Result; + function Scan_Set_With_Check return Test_Result; + + function Scan_Error_Check return Test_Result; + function Scan_Only_Error_Check return Test_Result; + function Scan_With_Error_Check return Test_Result; + function Scan_Set_Error_Check return Test_Result; + function Scan_Set_With_Error_Check return Test_Result; + + Lexer_Tests : Test_Array := + ((+"Stamp", Stamp_Check'Access), + (+"Ignore", Ignore_Check'Access), + (+"Scan", Scan_Check'Access), + (+"Scan_Only", Scan_Only_Check'Access), + (+"Scan_With", Scan_With_Check'Access), + (+"Scan_Set", Scan_Set_Check'Access), + (+"Scan_Set_With", Scan_Set_With_Check'Access), + (+"Scan Exception", Scan_Error_Check'Access), + (+"Scan_Only Exception", Scan_Only_Error_Check'Access), + (+"Scan_With Exception", Scan_With_Error_Check'Access), + (+"Scan_Set Exception", Scan_Set_Error_Check'Access), + (+"Scan_Set_With Exception", Scan_Set_With_Error_Check'Access)); + + +end Rat_Tests.Lexer; + + diff --git a/test/ratnest-tests-tokens.adb b/test/rat_tests-tokens.adb index 41969fd..8bfb516 100644 --- a/test/ratnest-tests-tokens.adb +++ b/test/rat_tests-tokens.adb @@ -1,7 +1,10 @@ -separate (Ratnest.Tests) -package body Tokens is +with Packrat; + + +package body Rat_Tests.Tokens is + type My_Labels is (One, Two, Three); @@ -63,6 +66,6 @@ package body Tokens is end Store_Check; -end Tokens; +end Rat_Tests.Tokens; diff --git a/test/rat_tests-tokens.ads b/test/rat_tests-tokens.ads new file mode 100644 index 0000000..1804347 --- /dev/null +++ b/test/rat_tests-tokens.ads @@ -0,0 +1,22 @@ + + +with Unit_Tests; +use Unit_Tests; + + +package Rat_Tests.Tokens is + + + function Adjust_Check return Test_Result; + function Equals_Check return Test_Result; + function Store_Check return Test_Result; + + Tests : Test_Array := + ((+"Adjust", Adjust_Check'Access), + (+"Equals", Equals_Check'Access), + (+"Storage", Store_Check'Access)); + + +end Rat_Tests.Tokens; + + diff --git a/test/ratnest-tests-util.adb b/test/rat_tests-util.adb index ca5f235..fe1f890 100644 --- a/test/ratnest-tests-util.adb +++ b/test/rat_tests-util.adb @@ -1,7 +1,12 @@ -separate (Ratnest.Tests) -package body Util is +with Packrat.Util; + + +package body Rat_Tests.Util is + + + package PU renames Packrat.Util; function In_Set_Check @@ -503,6 +508,6 @@ package body Util is end Not_Whitespace_Check; -end Util; +end Rat_Tests.Util; diff --git a/test/rat_tests-util.ads b/test/rat_tests-util.ads new file mode 100644 index 0000000..1b4754a --- /dev/null +++ b/test/rat_tests-util.ads @@ -0,0 +1,48 @@ + + +with Unit_Tests; +use Unit_Tests; + + +package Rat_Tests.Util is + + + function In_Set_Check return Test_Result; + function Not_In_Set_Check return Test_Result; + + Set_Predicate_Tests : Test_Array := + ((+"In_Set", In_Set_Check'Access), + (+"Not_In_Set", Not_In_Set_Check'Access)); + + + function Is_Digit_Check return Test_Result; + function Is_Hex_Check return Test_Result; + function Is_Letter_Check return Test_Result; + function Is_Alphanumeric_Check return Test_Result; + function Is_Punctuation_Check return Test_Result; + function Is_ASCII_Check return Test_Result; + function Is_Extended_ASCII_Check return Test_Result; + function Is_Space_Check return Test_Result; + function Is_Linespace_Check return Test_Result; + function Is_End_Of_Line_Check return Test_Result; + function Is_Whitespace_Check return Test_Result; + function Not_Whitespace_Check return Test_Result; + + Predicate_Tests : Test_Array := + ((+"Is_Digit", Is_Digit_Check'Access), + (+"Is_Hex", Is_Hex_Check'Access), + (+"Is_Letter", Is_Letter_Check'Access), + (+"Is_Alphanumeric", Is_Alphanumeric_Check'Access), + (+"Is_Punctuation", Is_Punctuation_Check'Access), + (+"Is_ASCII", Is_ASCII_Check'Access), + (+"Is_Extended_ASCII", Is_Extended_ASCII_Check'Access), + (+"Is_Space", Is_Space_Check'Access), + (+"Is_Linespace", Is_Linespace_Check'Access), + (+"Is_End_Of_Line", Is_End_Of_Line_Check'Access), + (+"Is_Whitespace", Is_Whitespace_Check'Access), + (+"Not_Whitespace", Not_Whitespace_Check'Access)); + + +end Rat_Tests.Util; + + diff --git a/test/rat_tests.ads b/test/rat_tests.ads new file mode 100644 index 0000000..9593667 --- /dev/null +++ b/test/rat_tests.ads @@ -0,0 +1,22 @@ + + +with + + Ada.Strings.Unbounded, + Ada.Characters.Latin_1, + Ada.Strings.Maps, + Ada.Exceptions; + + +package Rat_Tests is + + + package SU renames Ada.Strings.Unbounded; + package Latin renames Ada.Characters.Latin_1; + package Strmaps renames Ada.Strings.Maps; + package Except renames Ada.Exceptions; + + +end Rat_Tests; + + diff --git a/test/ratnest-tests-graphs.adb b/test/ratnest-tests-graphs.adb deleted file mode 100644 index 24b03c9..0000000 --- a/test/ratnest-tests-graphs.adb +++ /dev/null @@ -1,140 +0,0 @@ - - -separate (Ratnest.Tests) -package body Graphs is - - - type My_Labels is (One, Two, Three, Four, Five, Six); - - package My_Graphs is new Packrat.Graphs (My_Labels, Character, String); - - - use type My_Graphs.Node; - use type My_Graphs.Cursor; - use type My_Graphs.Graph; - - - function Node_Check - return Test_Result - is - Leafeon : My_Graphs.Node := My_Graphs.Leaf ("abc", 1, 3); - Brancheon : My_Graphs.Node := My_Graphs.Branch (One, 4, 3); - begin - if My_Graphs.Elements (Leafeon) /= "abc" or My_Graphs.Label (Brancheon) /= One or - My_Graphs.Start (Leafeon) /= 1 or My_Graphs.Start (Brancheon) /= 4 or - My_Graphs.Finish (Leafeon) /= 3 or My_Graphs.Finish (Brancheon) /= 3 - then - return Fail; - end if; - return Pass; - end Node_Check; - - - function Empty_Check - return Test_Result is - begin - if not My_Graphs.Empty_Graph.Is_Empty or - not My_Graphs.Is_Nothing (My_Graphs.No_Position) - then - return Fail; - end if; - return Pass; - end Empty_Check; - - - function Attachment_Check - return Test_Result - is - Leaf1 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); - Leaf2 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("def", 4, 6)); - Leaf3 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 4, 6)); - Leaf4 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("def", 1, 3)); - - Brancheon : My_Graphs.Graph := - My_Graphs.Singleton (My_Graphs.Branch (Three, 1, 15)); - - Merge1 : My_Graphs.Graph := Leaf1; - Merge2 : My_Graphs.Graph := Leaf3; - Merge3 : My_Graphs.Graph := Brancheon; - - Cursor1 : My_Graphs.Cursor := Merge3.Root (1); - begin - Merge1.Append (Leaf2); - Merge2.Prepend (Leaf4); - Merge3.Attach_Choice (Cursor1, Merge1); - - if Merge1.Root_Count /= 2 or else - Merge2.Root_Count /= 2 or else - Merge3.Root_Count /= 1 or else - not My_Graphs.Is_Leaf (Merge1.Root (1)) or else - not My_Graphs.Is_Leaf (Merge1.Root (2)) or else - My_Graphs.Elements (Merge1.Root (1)) /= "abc" or else - My_Graphs.Elements (Merge1.Root (2)) /= "def" or else - not My_Graphs.Is_Leaf (Merge2.Root (1)) or else - not My_Graphs.Is_Leaf (Merge2.Root (2)) or else - My_Graphs.Elements (Merge2.Root (1)) /= "def" or else - My_Graphs.Elements (Merge2.Root (2)) /= "abc" or else - not My_Graphs.Is_Branch (Merge3.Root (1)) or else - My_Graphs.Label (Cursor1) /= Three or else - My_Graphs.Child_Count (Cursor1) /= 2 or else - My_Graphs.Elements (My_Graphs.First_Child (Cursor1)) /= "abc" or else - My_Graphs.Elements (My_Graphs.Last_Child (Cursor1)) /= "def" - then - return Fail; - end if; - return Pass; - end Attachment_Check; - - - function Find_Check - return Test_Result - is - Leafeon : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); - Brancheon : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Branch (One, 1, 5)); - Combined : My_Graphs.Graph := Brancheon; - begin - Combined.Attach_Choice (Combined.Root (1), Leafeon); - declare - Expected_Result : My_Graphs.Cursor := My_Graphs.First_Child (Combined.Root (1)); - begin - if Combined.Find ("abc") /= Expected_Result or - Combined.Find ("def") /= My_Graphs.No_Position or - Brancheon.Find ("any") /= My_Graphs.No_Position - then - return Fail; - end if; - end; - return Pass; - end Find_Check; - - - function Find_Subgraph_Check - return Test_Result - is - Leafeon : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); - Branch1 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Branch (One, 1, 4)); - Branch2 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Branch (Two, 1, 5)); - Combined : My_Graphs.Graph := Branch2; - - My_Cursor : My_Graphs.Cursor := Combined.Root (1); - begin - Combined.Attach_Choice (My_Cursor, Branch1); - My_Cursor := My_Graphs.First_Child (My_Cursor); - Combined.Attach_Choice (My_Cursor, Leafeon); - - declare - Expected_Result : My_Graphs.Cursor := My_Graphs.First_Child (My_Cursor); - begin - if My_Graphs.Find_In_Subgraph (My_Cursor, "abc") /= Expected_Result or - My_Graphs.Find_In_Subgraph (My_Cursor, "def") /= My_Graphs.No_Position - then - return Fail; - end if; - end; - return Pass; - end Find_Subgraph_Check; - - -end Graphs; - - diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb deleted file mode 100644 index dfc8dec..0000000 --- a/test/ratnest-tests.adb +++ /dev/null @@ -1,32 +0,0 @@ - - -with - - Ada.Characters.Latin_1, - Ada.Strings.Maps, - Ada.Exceptions, - Packrat.Lexer.Debug, - Packrat.Graphs, - Packrat.Util; - - -package body Ratnest.Tests is - - - package Latin renames Ada.Characters.Latin_1; - package Strmaps renames Ada.Strings.Maps; - package Except renames Ada.Exceptions; - package PE renames Packrat.Errors; - package PU renames Packrat.Util; - - - package body Errors is separate; - package body Tokens is separate; - package body Lexer is separate; - package body Graphs is separate; - package body Util is separate; - - -end Ratnest.Tests; - - diff --git a/test/ratnest-tests.ads b/test/ratnest-tests.ads deleted file mode 100644 index bd0b4fe..0000000 --- a/test/ratnest-tests.ads +++ /dev/null @@ -1,186 +0,0 @@ - - -package Ratnest.Tests is - - - package Errors is - - function Valid_Message_Check return Test_Result; - function Valid_Identifier_Check return Test_Result; - function Join_Check return Test_Result; - function Encode_1_Check return Test_Result; - function Encode_2_Check return Test_Result; - function Encode_3_Check return Test_Result; - function Encode_4_Check return Test_Result; - function Decode_Check return Test_Result; - - Tests : Test_Array := - ((+"Valid_Message", Valid_Message_Check'Access), - (+"Valid_Identifier", Valid_Identifier_Check'Access), - (+"Join", Join_Check'Access), - (+"Encode_1", Encode_1_Check'Access), - (+"Encode_2", Encode_2_Check'Access), - (+"Encode_3", Encode_3_Check'Access), - (+"Encode_4", Encode_4_Check'Access), - (+"Decode", Decode_Check'Access)); - - end Errors; - - - - - package Tokens is - - function Adjust_Check return Test_Result; - function Equals_Check return Test_Result; - function Store_Check return Test_Result; - - Tests : Test_Array := - ((+"Adjust", Adjust_Check'Access), - (+"Equals", Equals_Check'Access), - (+"Storage", Store_Check'Access)); - - end Tokens; - - - - - package Lexer is - - function Join_Check return Test_Result; - function Equals_Check return Test_Result; - - function Sequence_Check return Test_Result; - function Count_Check return Test_Result; - function Many_Check return Test_Result; - function Many_Until_Check return Test_Result; - - function Satisfy_Check return Test_Result; - function Satisfy_With_Check return Test_Result; - function Match_Check return Test_Result; - function Match_With_Check return Test_Result; - function Multimatch_Check return Test_Result; - function Take_Check return Test_Result; - function Take_While_Check return Test_Result; - function Take_Until_Check return Test_Result; - - function Line_End_Check return Test_Result; - function Input_End_Check return Test_Result; - - Combinator_Tests : Test_Array := - ((+"Join", Join_Check'Access), - (+"Equals", Equals_Check'Access), - (+"Sequence", Sequence_Check'Access), - (+"Count", Count_Check'Access), - (+"Many", Many_Check'Access), - (+"Many_Until", Many_Until_Check'Access), - (+"Satisfy", Satisfy_Check'Access), - (+"Satisfy With", Satisfy_With_Check'Access), - (+"Match", Match_Check'Access), - (+"Match With", Match_With_Check'Access), - (+"Multimatch", Multimatch_Check'Access), - (+"Take", Take_Check'Access), - (+"Take While", Take_While_Check'Access), - (+"Take Until", Take_Until_Check'Access), - (+"Line End", Line_End_Check'Access), - (+"Input_End", Input_End_Check'Access)); - - - function Stamp_Check return Test_Result; - function Ignore_Check return Test_Result; - - function Scan_Check return Test_Result; - function Scan_Only_Check return Test_Result; - function Scan_With_Check return Test_Result; - function Scan_Set_Check return Test_Result; - function Scan_Set_With_Check return Test_Result; - - function Scan_Error_Check return Test_Result; - function Scan_Only_Error_Check return Test_Result; - function Scan_With_Error_Check return Test_Result; - function Scan_Set_Error_Check return Test_Result; - function Scan_Set_With_Error_Check return Test_Result; - - Lexer_Tests : Test_Array := - ((+"Stamp", Stamp_Check'Access), - (+"Ignore", Ignore_Check'Access), - (+"Scan", Scan_Check'Access), - (+"Scan_Only", Scan_Only_Check'Access), - (+"Scan_With", Scan_With_Check'Access), - (+"Scan_Set", Scan_Set_Check'Access), - (+"Scan_Set_With", Scan_Set_With_Check'Access), - (+"Scan Exception", Scan_Error_Check'Access), - (+"Scan_Only Exception", Scan_Only_Error_Check'Access), - (+"Scan_With Exception", Scan_With_Error_Check'Access), - (+"Scan_Set Exception", Scan_Set_Error_Check'Access), - (+"Scan_Set_With Exception", Scan_Set_With_Error_Check'Access)); - - end Lexer; - - - - - package Graphs is - - function Node_Check return Test_Result; - - function Empty_Check return Test_Result; - function Attachment_Check return Test_Result; - function Find_Check return Test_Result; - function Find_Subgraph_Check return Test_Result; - - Graph_Tests : Test_Array := - ((+"Node", Node_Check'Access), - (+"Emptiness", Empty_Check'Access), - (+"Attachment", Attachment_Check'Access), - (+"Find", Find_Check'Access), - (+"Find_Subgraph", Find_Subgraph_Check'Access)); - - end Graphs; - - - - - package Util is - - function In_Set_Check return Test_Result; - function Not_In_Set_Check return Test_Result; - - Set_Predicate_Tests : Test_Array := - ((+"In_Set", In_Set_Check'Access), - (+"Not_In_Set", Not_In_Set_Check'Access)); - - - function Is_Digit_Check return Test_Result; - function Is_Hex_Check return Test_Result; - function Is_Letter_Check return Test_Result; - function Is_Alphanumeric_Check return Test_Result; - function Is_Punctuation_Check return Test_Result; - function Is_ASCII_Check return Test_Result; - function Is_Extended_ASCII_Check return Test_Result; - function Is_Space_Check return Test_Result; - function Is_Linespace_Check return Test_Result; - function Is_End_Of_Line_Check return Test_Result; - function Is_Whitespace_Check return Test_Result; - function Not_Whitespace_Check return Test_Result; - - Predicate_Tests : Test_Array := - ((+"Is_Digit", Is_Digit_Check'Access), - (+"Is_Hex", Is_Hex_Check'Access), - (+"Is_Letter", Is_Letter_Check'Access), - (+"Is_Alphanumeric", Is_Alphanumeric_Check'Access), - (+"Is_Punctuation", Is_Punctuation_Check'Access), - (+"Is_ASCII", Is_ASCII_Check'Access), - (+"Is_Extended_ASCII", Is_Extended_ASCII_Check'Access), - (+"Is_Space", Is_Space_Check'Access), - (+"Is_Linespace", Is_Linespace_Check'Access), - (+"Is_End_Of_Line", Is_End_Of_Line_Check'Access), - (+"Is_Whitespace", Is_Whitespace_Check'Access), - (+"Not_Whitespace", Not_Whitespace_Check'Access)); - - end Util; - - -end Ratnest.Tests; - - diff --git a/test/ratnest.adb b/test/ratnest.adb deleted file mode 100644 index d063b41..0000000 --- a/test/ratnest.adb +++ /dev/null @@ -1,34 +0,0 @@ - - -with - - Ada.Text_IO; - -use - - Ada.Text_IO; - - -package body Ratnest is - - - procedure Run_Tests - (To_Run : in Test_Array) - is - Total_Count : Natural := To_Run'Length; - Failed_Count : Natural := 0; - begin - for T of To_Run loop - if T.Func.all = Fail then - Put_Line ("Failed test " & (-T.Name)); - Failed_Count := Failed_Count + 1; - end if; - end loop; - Put_Line ("Test results" & Integer'Image (Total_Count - Failed_Count) & - " out of" & Integer'Image (Total_Count)); - end Run_Tests; - - -end Ratnest; - - diff --git a/test/ratnest.ads b/test/ratnest.ads deleted file mode 100644 index 24a5162..0000000 --- a/test/ratnest.ads +++ /dev/null @@ -1,47 +0,0 @@ - - -with - - Ada.Strings.Unbounded; - - -package Ratnest is - - - type Test_Result is (Fail, Pass); - - type Test_Function is access function return Test_Result; - - type Test is record - Name : Ada.Strings.Unbounded.Unbounded_String; - Func : Test_Function; - end record; - - type Test_Array is array (Positive range <>) of Test; - - - - - procedure Run_Tests - (To_Run : in Test_Array); - - - - - function "+" - (S : in String) - return Ada.Strings.Unbounded.Unbounded_String - renames Ada.Strings.Unbounded.To_Unbounded_String; - - function "-" - (US : in Ada.Strings.Unbounded.Unbounded_String) - return String - renames Ada.Strings.Unbounded.To_String; - - -private - - -end Ratnest; - - diff --git a/test/test_main.adb b/test/test_main.adb index a5d5fc5..4cba5ec 100644 --- a/test/test_main.adb +++ b/test/test_main.adb @@ -3,19 +3,41 @@ with Ada.Text_IO, + Ada.Command_Line, + Ada.Characters.Latin_1, + Unit_Tests, Packrat, - Ratnest.Tests; + Rat_Tests.Errors, + Rat_Tests.Tokens, + Rat_Tests.Lexer, + Rat_Tests.Util; use Ada.Text_IO, - Ratnest, - Ratnest.Tests; + Unit_Tests; procedure Test_Main is + package Latin renames Ada.Characters.Latin_1; + + + Help_String : String := + "Runs unit tests on the Packrat parser combinator library." & Latin.LF & + "Usage: rattest [switches]" & Latin.LF & + Latin.LF & + "Valid switches:" & Latin.LF & + "--help" & Latin.HT & Latin.HT & "Shows this information" & Latin.LF & + "--verbose" & Latin.HT & "Enables extra verbosity" & Latin.LF & + Latin.LF & + "All other command line input will be ignored."; + + + How_Verbose : Unit_Tests.Verbosity := Weak; + + type My_Labels is (A, B, C); package My_Tokens is new Packrat.Tokens (My_Labels, Character, String); @@ -26,37 +48,48 @@ procedure Test_Main is begin + for N in 1 .. Ada.Command_Line.Argument_Count loop + if Ada.Command_Line.Argument (N) = "--help" then + Put_Line (Help_String); + return; + end if; + end loop; + + for N in 1 .. Ada.Command_Line.Argument_Count loop + if Ada.Command_Line.Argument (N) = "--verbose" then + How_Verbose := Strong; + exit; + end if; + end loop; + + Put_Line ("Running tests for Packrat.Errors..."); - Run_Tests (Errors.Tests); + Run_Tests (Rat_Tests.Errors.Tests, How_Verbose); New_Line; Put_Line ("Displaying Error_Message debug string output example:"); Put (Packrat.Errors.Debug_String (Err)); New_Line; Put_Line ("Running tests for Packrat.Tokens..."); - Run_Tests (Tokens.Tests); + Run_Tests (Rat_Tests.Tokens.Tests, How_Verbose); New_Line; Put_Line ("Displaying Token debug string output example:"); Put (My_Tokens.Debug_String (Tok)); New_Line; Put_Line ("Running tests for Packrat.Lexer combinators..."); - Run_Tests (Lexer.Combinator_Tests); + Run_Tests (Rat_Tests.Lexer.Combinator_Tests, How_Verbose); New_Line; Put_Line ("Running tests for Packrat.Lexer lexing..."); - Run_Tests (Lexer.Lexer_Tests); - New_Line; - - Put_Line ("Running tests for Packrat.Graphs..."); - Run_Tests (Graphs.Graph_Tests); + Run_Tests (Rat_Tests.Lexer.Lexer_Tests, How_Verbose); New_Line; Put_Line ("Running tests for Packrat.Util..."); Put_Line ("Testing set predicates..."); - Run_Tests (Util.Set_Predicate_Tests); + Run_Tests (Rat_Tests.Util.Set_Predicate_Tests, How_Verbose); Put_Line ("Testing ordinary predicates..."); - Run_Tests (Util.Predicate_Tests); + Run_Tests (Rat_Tests.Util.Predicate_Tests, How_Verbose); end Test_Main; @@ -1,6 +1,6 @@ -with "packrat"; +with "packrat", "basic_unit_test"; project Tests is @@ -16,7 +16,7 @@ project Tests is package Builder is - for Executable("test_main.adb") use "testrat"; + for Executable("test_main.adb") use "rattest"; end Builder; |