ADDED src/natools-static_hash_maps-s_expressions-command_maps-test.adb Index: src/natools-static_hash_maps-s_expressions-command_maps-test.adb ================================================================== --- src/natools-static_hash_maps-s_expressions-command_maps-test.adb +++ src/natools-static_hash_maps-s_expressions-command_maps-test.adb @@ -0,0 +1,26 @@ +-- Generated at 2014-05-29 18:32:55 +0000 by Natools.Static_Hash_Maps +-- from natools-static_hash_maps-s_expressions-hash_maps.sx + +with Natools.Static_Hash_Maps.S_Expressions.Command_Pkg; +with Natools.Static_Hash_Maps.S_Expressions.Command_Map; +function Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test + return Boolean is +begin + for I in Map_1_Keys'Range loop + if Natools.Static_Hash_Maps.S_Expressions.Command_Pkg.Hash + (Map_1_Keys (I).all) /= I + then + return False; + end if; + end loop; + + for I in Map_2_Keys'Range loop + if Natools.Static_Hash_Maps.S_Expressions.Command_Map.Hash + (Map_2_Keys (I).all) /= I + then + return False; + end if; + end loop; + + return True; +end Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test; ADDED src/natools-static_hash_maps-s_expressions-command_maps-test.ads Index: src/natools-static_hash_maps-s_expressions-command_maps-test.ads ================================================================== --- src/natools-static_hash_maps-s_expressions-command_maps-test.ads +++ src/natools-static_hash_maps-s_expressions-command_maps-test.ads @@ -0,0 +1,5 @@ +-- Generated at 2014-05-29 18:32:55 +0000 by Natools.Static_Hash_Maps +-- from natools-static_hash_maps-s_expressions-hash_maps.sx + +function Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test + return Boolean; Index: src/natools-static_hash_maps-s_expressions-hash_maps.sx ================================================================== --- src/natools-static_hash_maps-s_expressions-hash_maps.sx +++ src/natools-static_hash_maps-s_expressions-hash_maps.sx @@ -1,7 +1,8 @@ (Natools.Static_Hash_Maps.S_Expressions.Command_Maps private + (test-function Test) (Package_Command (hash-package Natools.Static_Hash_Maps.S_Expressions.Command_Pkg) (function To_Package_Command) (not-found Extra_Declarations) (nodes ADDED tests/natools-static_hash_maps-s_expressions-tests.adb Index: tests/natools-static_hash_maps-s_expressions-tests.adb ================================================================== --- tests/natools-static_hash_maps-s_expressions-tests.adb +++ tests/natools-static_hash_maps-s_expressions-tests.adb @@ -0,0 +1,47 @@ +------------------------------------------------------------------------------ +-- Copyright (c) 2014, Natacha Porté -- +-- -- +-- Permission to use, copy, modify, and distribute this software for any -- +-- purpose with or without fee is hereby granted, provided that the above -- +-- copyright notice and this permission notice appear in all copies. -- +-- -- +-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- +-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- +-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- +-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- +-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- +-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- +-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- +------------------------------------------------------------------------------ + +with Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test; + +package body Natools.Static_Hash_Maps.S_Expressions.Tests is + + ------------------------- + -- Complete Test Suite -- + ------------------------- + + procedure All_Tests (Report : in out NT.Reporter'Class) is + begin + Test_Hash_Functions (Report); + end All_Tests; + + + + ----------------------- + -- Inidividual Tests -- + ----------------------- + + procedure Test_Hash_Functions (Report : in out NT.Reporter'Class) is + Test : NT.Test := Report.Item + ("Hash functions for S-expression interpreter"); + begin + if not S_Expressions.Command_Maps.Test then + Test.Fail; + end if; + exception + when Error : others => Test.Report_Exception (Error); + end Test_Hash_Functions; + +end Natools.Static_Hash_Maps.S_Expressions.Tests; ADDED tests/natools-static_hash_maps-s_expressions-tests.ads Index: tests/natools-static_hash_maps-s_expressions-tests.ads ================================================================== --- tests/natools-static_hash_maps-s_expressions-tests.ads +++ tests/natools-static_hash_maps-s_expressions-tests.ads @@ -0,0 +1,39 @@ +------------------------------------------------------------------------------ +-- Copyright (c) 2014, Natacha Porté -- +-- -- +-- Permission to use, copy, modify, and distribute this software for any -- +-- purpose with or without fee is hereby granted, provided that the above -- +-- copyright notice and this permission notice appear in all copies. -- +-- -- +-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- +-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- +-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- +-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- +-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- +-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- +-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- +------------------------------------------------------------------------------ + +------------------------------------------------------------------------------ +-- Natools.Static_Hash_Maps.S_Expressions.Tests provides a very limited -- +-- test suite for the static hash map generator. -- +-- Since Natools.Static_Hash_Maps is only a code generator, it is not used -- +-- directly and does not need much testing. Testing should instead target -- +-- the generated code, so that issues with the generator show up in when -- +-- compiling or testing the generated code. -- +-- Currently the test suite here only runs the generated self-test of the -- +-- hash map used to decode S-expressions, so that generate_static_hash_map -- +-- tool can be run without silent error. -- +------------------------------------------------------------------------------ + +with Natools.Tests; + +package Natools.Static_Hash_Maps.S_Expressions.Tests is + + package NT renames Natools.Tests; + + procedure All_Tests (Report : in out NT.Reporter'Class); + + procedure Test_Hash_Functions (Report : in out NT.Reporter'Class); + +end Natools.Static_Hash_Maps.S_Expressions.Tests; Index: tests/test_all.adb ================================================================== --- tests/test_all.adb +++ tests/test_all.adb @@ -32,10 +32,11 @@ with Natools.S_Expressions.Lockable.Tests; with Natools.S_Expressions.Parsers.Tests; with Natools.S_Expressions.Printers.Tests; with Natools.S_Expressions.Printers.Pretty.Tests; with Natools.S_Expressions.Printers.Pretty.Config.Tests; +with Natools.Static_Hash_Maps.S_Expressions.Tests; with Natools.String_Slice_Set_Tests; with Natools.String_Slice_Tests; with Natools.Tests.Text_IO; procedure Test_All is @@ -120,10 +121,14 @@ Report.End_Section; Report.Section ("S_Expressions.Printers.Pretty.Config"); Natools.S_Expressions.Printers.Pretty.Config.Tests.All_Tests (Report); Report.End_Section; + + Report.Section ("Static_Hash_Maps.S_Expressions"); + Natools.Static_Hash_Maps.S_Expressions.Tests.All_Tests (Report); + Report.End_Section; Report.Section ("String_Slices"); Natools.String_Slice_Tests.All_Tests (Report); Report.End_Section;