Natools

Check-in [f1bcc5d576]
Login
Overview
Comment:smaz-tests: add sample strings without variable-length verbatim
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f1bcc5d576935951f5553c26a90d265b5c95ab4f
User & Date: nat on 2017-02-16 20:56:01
Other Links: manifest | tags
Context
2017-02-17
21:33
smaz: fix off-by-one error in Verbatim_Size check-in: 1f3ace98c0 user: nat tags: trunk
2017-02-16
20:56
smaz-tests: add sample strings without variable-length verbatim check-in: f1bcc5d576 user: nat tags: trunk
2017-02-15
22:57
coverage.sh: use gprbuild instead of gnatmake check-in: 89d897146c user: nat tags: trunk
Changes

Modified tests/natools-smaz-tests.adb from [28f079a816] to [c4839bfc52].

1
2

3
4
5
6
7
8
9
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
1

2
3
4
5
6
7
8
9
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

-
+


















+
+













+
+
+
+
+
+
+
+







------------------------------------------------------------------------------
-- Copyright (c) 2015-2016, Natacha Porté                                   --
-- Copyright (c) 2015-2017, 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 Ada.Strings.Unbounded;
with Natools.Smaz.Original;

package body Natools.Smaz.Tests is

   function Dict_Without_VLV return Dictionary;

   function Image (S : Ada.Streams.Stream_Element_Array) return String;

   procedure Roundtrip_Test
     (Test : in out NT.Test;
      Dict : in Dictionary;
      Decompressed : in String;
      Compressed : in Ada.Streams.Stream_Element_Array);


   ------------------------------
   -- Local Helper Subprograms --
   ------------------------------

   function Dict_Without_VLV return Dictionary is
   begin
      return Dict : Dictionary := Original.Dictionary do
         Dict.Variable_Length_Verbatim := False;
      end return;
   end Dict_Without_VLV;


   function Image (S : Ada.Streams.Stream_Element_Array) return String is
      use Ada.Strings.Unbounded;
      Result : Unbounded_String;
   begin
      for I in S'Range loop
         Append (Result, Ada.Streams.Stream_Element'Image (S (I)));
127
128
129
130
131
132
133

134
135
136
137
138
139
140
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151







+







   -------------------------
   -- Complete Test Suite --
   -------------------------

   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Sample_Strings (Report);
      Sample_Strings_Without_VLV (Report);
   end All_Tests;



   ----------------------
   -- Individual Tests --
   ----------------------
177
178
179
180
181
182
183













































184
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

      Roundtrip_Test (Test, Original.Dictionary,
         ": : : :",
         (255, 6, 58, 32, 58, 32, 58, 32, 58));
   exception
      when Error : others => Test.Report_Exception (Error);
   end Sample_Strings;


   procedure Sample_Strings_Without_VLV (Report : in out NT.Reporter'Class) is
      Test : NT.Test
        := Report.Item ("Roundtrip on sample strings without VLV");
      Dict : constant Dictionary := Dict_Without_VLV;
   begin
      Roundtrip_Test (Test, Dict,
         "This is a small string",
         (255, 84, 76, 56, 172, 62, 173, 152, 62, 195, 70));
      Roundtrip_Test (Test, Dict,
         "foobar",
         (220, 6, 90, 79));
      Roundtrip_Test (Test, Dict,
         "the end",
         (1, 171, 61));
      Roundtrip_Test (Test, Dict,
         "not-a-g00d-Exampl333",
         (132, 204, 4, 204, 59, 254, 48, 48, 24, 204, 255, 69, 250, 4, 45,
           60, 22, 254, 51, 51, 255, 51));
      Roundtrip_Test (Test, Dict,
         "Smaz is a simple compression library",
         (255, 83, 173, 219, 56, 172, 62, 226, 60, 87, 161, 45, 60, 33, 166,
           107, 205, 8, 90, 130, 12, 83));
      Roundtrip_Test (Test, Dict,
         "Nothing is more difficult, and therefore more precious, "
           & "than to be able to decide",
         (255, 78, 223, 102, 99, 116, 45, 42, 11, 129, 44, 44, 131, 38, 22, 3,
           148, 63, 210, 68, 11, 45, 42, 11, 60, 33, 28, 144, 164, 36, 203,
           143, 96, 92, 25, 90, 87, 82, 165, 215, 237, 2));
      Roundtrip_Test (Test, Dict,
         "this is an example of what works very well with smaz",
         (155, 56, 172, 41, 2, 250, 4, 45, 60, 87, 32, 159, 135, 65, 42, 255,
           107, 23, 231, 71, 145, 152, 243, 227, 10, 173, 219));
      Roundtrip_Test (Test, Dict,
         "1000 numbers 2000 will 10 20 30 compress very little",
         (254, 49, 48, 254, 48, 48, 236, 38, 45, 92, 221, 0, 254, 50, 48,
           254, 48, 48, 243, 152, 0, 254, 49, 48, 0, 254, 50, 48, 0, 254, 51,
           48, 161, 45, 60, 33, 166, 0, 231, 71, 151, 3, 3, 87));
      Roundtrip_Test (Test, Dict,
         ": : : :",
         (254, 58, 32, 254, 58, 32, 254, 58, 32, 255, 58));
   exception
      when Error : others => Test.Report_Exception (Error);
   end Sample_Strings_Without_VLV;

end Natools.Smaz.Tests;

Modified tests/natools-smaz-tests.ads from [5b00cffab8] to [53fc4b3c2d].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- Copyright (c) 2016, Natacha Porté                                        --
-- Copyright (c) 2016-2017, 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         --
19
20
21
22
23
24
25

26
27
19
20
21
22
23
24
25
26
27
28







+


package Natools.Smaz.Tests is

   package NT renames Natools.Tests;

   procedure All_Tests (Report : in out NT.Reporter'Class);

   procedure Sample_Strings (Report : in out NT.Reporter'Class);
   procedure Sample_Strings_Without_VLV (Report : in out NT.Reporter'Class);

end Natools.Smaz.Tests;