Index: tests/natools-s_expressions-test_tools.adb ================================================================== --- tests/natools-s_expressions-test_tools.adb +++ tests/natools-s_expressions-test_tools.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2013, Natacha Porté -- +-- Copyright (c) 2013-2015, 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. -- -- -- @@ -11,10 +11,12 @@ -- 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.S_Expressions.Parsers; package body Natools.S_Expressions.Test_Tools is Hex_Digits : constant String := "0123456789ABCDEF"; @@ -481,10 +483,26 @@ Test_Tools.Test_Atom_Accessors (Test, Tested, Expected, Level, Context); end if; end Next_And_Check; + + function To_S_Expression (Text : String) return Caches.Reference is + begin + return To_S_Expression (To_Atom (Text)); + end To_S_Expression; + + + function To_S_Expression (Data : Atom) return Caches.Reference is + Stream : aliased Memory_Stream; + Parser : Parsers.Stream_Parser (Stream'Access); + begin + Stream.Write (Data); + Parser.Next; + return Caches.Move (Parser); + end To_S_Expression; + ------------------- -- Memory Stream -- ------------------- Index: tests/natools-s_expressions-test_tools.ads ================================================================== --- tests/natools-s_expressions-test_tools.ads +++ tests/natools-s_expressions-test_tools.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2013, Natacha Porté -- +-- Copyright (c) 2013-2015, 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. -- -- -- @@ -26,10 +26,11 @@ with Ada.Streams; with Natools.Tests; with Natools.S_Expressions.Atom_Buffers; +with Natools.S_Expressions.Caches; package Natools.S_Expressions.Test_Tools is pragma Preelaborate (Test_Tools); package NT renames Natools.Tests; @@ -85,10 +86,15 @@ Level : in Natural; Context : in String := ""); -- Call Tested.Next and check current event is Add_Atom with Expected, -- using Test_Atom_Accessors. + + function To_S_Expression (Text : String) return Caches.Reference; + function To_S_Expression (Data : Atom) return Caches.Reference; + -- Store a S-expression from its serialization + type Memory_Stream is new Ada.Streams.Root_Stream_Type with private; overriding procedure Read (Stream : in out Memory_Stream;