Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Apr 4, 2024
1 parent cc4c76c commit 3cd55d8
Showing 1 changed file with 41 additions and 21 deletions.
62 changes: 41 additions & 21 deletions lzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package lzip_test

import (
"math"
"testing"

"github.com/sorairolake/lzip-go"
Expand All @@ -14,75 +13,96 @@ import (
func TestHeaderSize(t *testing.T) {
t.Parallel()

if size := lzip.HeaderSize; size != 6 {
t.Errorf("expected header size `%v`, got `%v`", 6, size)
const expected = 6

if size := lzip.HeaderSize; size != expected {
t.Errorf("expected header size `%v`, got `%v`", expected, size)
}
}

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

if size := lzip.TrailerSize; size != 20 {
t.Errorf("expected trailer size `%v`, got `%v`", 20, size)
const expected = 20

if size := lzip.TrailerSize; size != expected {
t.Errorf("expected trailer size `%v`, got `%v`", expected, size)
}
}

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

if magic := lzip.Magic; magic != "LZIP" {
t.Errorf("expected magic number `%v`, got `%v`", "LZIP", magic)
const expected = "LZIP"

if magic := lzip.Magic; magic != expected {
t.Errorf("expected magic number `%v`, got `%v`", expected, magic)
}
}

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

if size := lzip.MagicSize; size != 4 {
t.Errorf("expected magic number size `%v`, got `%v`", 4, size)
const expected = 4

if size := lzip.MagicSize; size != expected {
t.Errorf("expected magic number size `%v`, got `%v`", expected, size)
}
}

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

if v0 := lzip.Version0; v0 != 0 {
t.Errorf("expected version number `%v`, got `%v`", 0, v0)
const (
expectedV0 = iota
expectedV1
)

if v0 := lzip.Version0; v0 != expectedV0 {
t.Errorf("expected version number `%v`, got `%v`", expectedV0, v0)
}

if v1 := lzip.Version1; v1 != 1 {
t.Errorf("expected version number `%v`, got `%v`", 1, v1)
if v1 := lzip.Version1; v1 != expectedV1 {
t.Errorf("expected version number `%v`, got `%v`", expectedV1, v1)
}
}

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

if size := lzip.MinDictSize; size != (1 << 12) {
t.Errorf("expected minimum dictionary size `%v`, got `%v`", (1 << 12), size)
const expected = 1 << 12

if size := lzip.MinDictSize; size != expected {
t.Errorf("expected minimum dictionary size `%v`, got `%v`", expected, size)
}
}

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

if size := lzip.MaxDictSize; size != (1 << 29) {
t.Errorf("expected maximum dictionary size `%v`, got `%v`", (1 << 29), size)
const expected = 1 << 29

if size := lzip.MaxDictSize; size != expected {
t.Errorf("expected maximum dictionary size `%v`, got `%v`", expected, size)
}
}

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

if size := uint32(lzip.DefaultDictSize); size != (8 * uint32(math.Pow(2.0, 20.0))) {
t.Errorf("expected default dictionary size `%v`, got `%v`", (8 * uint32(math.Pow(2.0, 20.0))), size)
const expected = 8 * (1 << 20)

if size := lzip.DefaultDictSize; size != expected {
t.Errorf("expected default dictionary size `%v`, got `%v`", expected, size)
}
}

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

if size := uint64(lzip.MaxMemberSize); size != (2 * uint64(math.Pow(2.0, 50.0))) {
t.Errorf("expected maximum member size `%v`, got `%v`", (2 * uint64(math.Pow(2.0, 50.0))), size)
const expected = 2 * (1 << 50)

if size := lzip.MaxMemberSize; size != expected {
t.Errorf("expected maximum member size `%v`, got `%v`", expected, size)
}
}

0 comments on commit 3cd55d8

Please sign in to comment.