10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
-- 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 Ada.Characters.Latin_1;
with Ada.Streams;
with Ada.Strings.Unbounded;
with Natools.S_Expressions;
with Natools.Smaz_256;
with Natools.Smaz_64;
with Natools.Smaz_Generic;
with Natools.Smaz_Original;
with Natools.Smaz_Test_Base_64_Hash;
package body Natools.Smaz_Tests is
generic
with package Smaz is new Natools.Smaz_Generic (<>);
procedure Generic_Roundtrip_Test
(Test : in out NT.Test;
Dict : in Smaz.Dictionary;
Decompressed : in String;
Compressed : in Ada.Streams.Stream_Element_Array);
function Image (S : Ada.Streams.Stream_Element_Array) return String;
function To_SEA (S : String) return Ada.Streams.Stream_Element_Array
renames Natools.S_Expressions.To_Atom;
-----------------------
-- Test Dictionaries --
-----------------------
LF : constant Character := Ada.Characters.Latin_1.LF;
Dict_64 : constant Natools.Smaz_64.Dictionary
:= (Last_Code => 59,
Values_Last => 119,
Variable_Length_Verbatim => False,
Max_Word_Length => 6,
Offsets => (2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18, 20, 22,
24, 25, 26, 28, 30, 31, 32, 36, 38, 40, 42, 44, 45, 47, 49, 51, 53,
56, 60, 63, 65, 68, 70, 72, 74, 76, 80, 82, 84, 88, 90, 92, 94, 98,
101, 102, 103, 105, 111, 112, 114, 115, 118),
Values => " ee stainruos l dt enescm pépd de lere ld"
& "e" & LF & "on cqumede mentes aiquen teerou r sque , is m q"
& "ueà v'tiweblogfanj." & LF & LF & "ch",
Hash => Natools.Smaz_Test_Base_64_Hash.Hash'Access);
------------------------------
-- Local Helper Subprograms --
------------------------------
function Image (S : Ada.Streams.Stream_Element_Array) return String is
|
200
201
202
203
204
205
206
207
|
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
Roundtrip_Test (Test, Smaz_Original.Dictionary,
": : : :",
(255, 6, 58, 32, 58, 32, 58, 32, 58));
exception
when Error : others => Test.Report_Exception (Error);
end Sample_Strings_256;
------------------------------
-- Individual Base-64 Tests --
------------------------------
procedure Sample_Strings_64 (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Roundtrip on sample strings");
begin
Roundtrip_Test (Test, Dict_64,
"Simple Test",
To_SEA ("+TBGSVYA+UBQE"));
-- <S>imp* <T>*t
exception
when Error : others => Test.Report_Exception (Error);
end Sample_Strings_64;
end Natools.Smaz_Tests;
|