Skip to content

Commit

Permalink
test: Update test data
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Jan 24, 2025
1 parent 63f6f7f commit 87f8e3d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 7 deletions.
38 changes: 38 additions & 0 deletions reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ func TestReader(t *testing.T) {
}
}

func TestReaderFromEmpty(t *testing.T) {
t.Parallel()

file, err := os.Open("testdata/em.lz")
if err != nil {
t.Fatal(err)
}

reader, err := lzip.NewReader(file)
if err != nil {
t.Fatal(err)
}

var buf bytes.Buffer
if _, err := io.Copy(&buf, reader); err != nil {
t.Fatal(err)
}

data := []byte{}

if !bytes.Equal(buf.Bytes(), data) {
t.Error("unexpected mismatch between uncompressed data and test data")
}
}

func TestReaderInvalidMagic(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -104,3 +129,16 @@ func TestReaderDictSizeTooSmall(t *testing.T) {
t.Errorf("expected too small dictionary size `%v`, got `%v`", expected, size)
}
}

func TestReaderNonZeroFirstByte(t *testing.T) {
t.Parallel()

file, err := os.Open("testdata/fox_nz.lz")
if err != nil {
t.Fatal(err)
}

if _, err := lzip.NewReader(file); err == nil {
t.Error("unexpected success")
}
}
6 changes: 3 additions & 3 deletions testdata/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
:lzd-url: https://www.nongnu.org/lzip/lzd.html
:lzd-download-url: https://download.savannah.gnu.org/releases/lzip/lzd

Test data files imported those of {lzd-url}[lzd] version 1.4.
Test data files imported those of {lzd-url}[lzd] version 1.5.

.These can be obtained from either
* {lzd-download-url}/lzd-1.4.tar.lz
* {lzd-download-url}/lzd-1.4.tar.gz
* {lzd-download-url}/lzd-1.5.tar.lz
* {lzd-download-url}/lzd-1.5.tar.gz
Binary file added testdata/em.lz
Binary file not shown.
3 changes: 3 additions & 0 deletions testdata/em.lz.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2013 Antonio Diaz Diaz

SPDX-License-Identifier: BSD-2-Clause
Binary file added testdata/fox_nz.lz
Binary file not shown.
3 changes: 3 additions & 0 deletions testdata/fox_nz.lz.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2013 Antonio Diaz Diaz

SPDX-License-Identifier: BSD-2-Clause
6 changes: 2 additions & 4 deletions testdata/test.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -339,8 +338,7 @@ Public License instead of this License.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down
Binary file modified testdata/test.txt.lz
Binary file not shown.

0 comments on commit 87f8e3d

Please sign in to comment.