Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Update test data #46

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.