diff --git a/reader_test.go b/reader_test.go index aaa43b2..b9adeb4 100644 --- a/reader_test.go +++ b/reader_test.go @@ -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() @@ -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") + } +} diff --git a/testdata/README.adoc b/testdata/README.adoc index 443eaa7..9254220 100644 --- a/testdata/README.adoc +++ b/testdata/README.adoc @@ -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 diff --git a/testdata/em.lz b/testdata/em.lz new file mode 100644 index 0000000..ec60725 Binary files /dev/null and b/testdata/em.lz differ diff --git a/testdata/em.lz.license b/testdata/em.lz.license new file mode 100644 index 0000000..a329729 --- /dev/null +++ b/testdata/em.lz.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2013 Antonio Diaz Diaz + +SPDX-License-Identifier: BSD-2-Clause diff --git a/testdata/fox_nz.lz b/testdata/fox_nz.lz new file mode 100644 index 0000000..44a4b58 Binary files /dev/null and b/testdata/fox_nz.lz differ diff --git a/testdata/fox_nz.lz.license b/testdata/fox_nz.lz.license new file mode 100644 index 0000000..a329729 --- /dev/null +++ b/testdata/fox_nz.lz.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2013 Antonio Diaz Diaz + +SPDX-License-Identifier: BSD-2-Clause diff --git a/testdata/test.txt b/testdata/test.txt index 9196a3a..423f0c0 100644 --- a/testdata/test.txt +++ b/testdata/test.txt @@ -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. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -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. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/testdata/test.txt.lz b/testdata/test.txt.lz index 22cea6e..5dc169f 100644 Binary files a/testdata/test.txt.lz and b/testdata/test.txt.lz differ