Differences From Artifact [f615a75ea1]:
- File
tests/natools-smaz-tests.adb
— part of check-in
[e2fbcb314b]
at
2016-09-14 21:44:56
on branch trunk
— smaz-tests: make round-trip test really a round-trip
Since there are multiple encoded sequence that decompress into the same original string, it is much more important to check that compressed data really decompress into the original data than to check that it matches exactly the expected byte sequence (user: nat size: 5993)
To Artifact [89531cdf45]:
- File tests/natools-smaz-tests.adb — part of check-in [21fd02233a] at 2016-09-18 21:06:16 on branch trunk — smaz-tests: rewrite Roundtrip_Test to make both roundtrip directions (user: nat size: 6746)
| ︙ | ︙ | |||
48 49 50 51 52 53 54 |
(Test : in out NT.Test;
Dict : in Dictionary;
Decompressed : in String;
Compressed : in Ada.Streams.Stream_Element_Array)
is
use type Ada.Streams.Stream_Element_Array;
use type Ada.Streams.Stream_Element_Offset;
| | > > > > | | < < | > > > > > > > > > | | > | > > > > > > | > > > > > > > > > | | > | | < | < > | < < | > > | < > > | > > | | > | < | < < | < | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
(Test : in out NT.Test;
Dict : in Dictionary;
Decompressed : in String;
Compressed : in Ada.Streams.Stream_Element_Array)
is
use type Ada.Streams.Stream_Element_Array;
use type Ada.Streams.Stream_Element_Offset;
begin
declare
First_OK : Boolean := False;
begin
declare
Buffer : constant Ada.Streams.Stream_Element_Array
:= Compress (Dict, Decompressed);
begin
First_OK := True;
if Buffer /= Compressed then
Test.Fail ("Bad compression of """ & Decompressed & '"');
Test.Info ("Found: " & Image (Buffer));
Test.Info ("Expected:" & Image (Compressed));
declare
Round : constant String := Decompress (Dict, Buffer);
begin
if Round /= Decompressed then
Test.Info ("Roundtrip failed, got: """ & Round & '"');
else
Test.Info ("Roundtrip OK");
end if;
end;
end if;
end;
exception
when Error : others =>
if not First_OK then
Test.Info ("During compression of """ & Decompressed & '"');
end if;
Test.Report_Exception (Error, NT.Fail);
end;
declare
First_OK : Boolean := False;
begin
declare
Buffer : constant String := Decompress (Dict, Compressed);
begin
First_OK := True;
if Buffer /= Decompressed then
Test.Fail ("Bad decompression of " & Image (Compressed));
Test.Info ("Found: """ & Buffer & '"');
Test.Info ("Expected:""" & Decompressed & '"');
declare
Round : constant Ada.Streams.Stream_Element_Array
:= Compress (Dict, Buffer);
begin
if Round /= Compressed then
Test.Info ("Roundtrip failed, got: " & Image (Round));
else
Test.Info ("Roundtrip OK");
end if;
end;
end if;
end;
exception
when Error : others =>
if not First_OK then
Test.Info ("During compression of " & Image (Compressed));
end if;
Test.Report_Exception (Error, NT.Fail);
end;
end Roundtrip_Test;
-------------------------
-- Complete Test Suite --
|
| ︙ | ︙ |