From 376591384ae0e6a434c3aeae13ea7a49aef3dbef Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Mon, 29 Apr 2019 16:33:15 -0600 Subject: [PATCH] add more to tests --- src/compress/compress_test.go | 12 ++++++++++++ src/crypt/crypt_test.go | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/compress/compress_test.go b/src/compress/compress_test.go index 563883df..b8682ff6 100644 --- a/src/compress/compress_test.go +++ b/src/compress/compress_test.go @@ -75,4 +75,16 @@ func TestCompress(t *testing.T) { dataRateSavings = 100 * (1.0 - float64(len(compressedB))/float64(len(fable))) fmt.Printf("Level -2: %2.0f%% percent space savings\n", dataRateSavings) assert.True(t, len(compressedB) < len(fable)) + + data := make([]byte, 4096) + rand.Read(data) + compressedB = CompressWithOption(data, -2) + dataRateSavings = 100 * (1.0 - float64(len(compressedB))/float64(len(data))) + fmt.Printf("random, Level -2: %2.0f%% percent space savings\n", dataRateSavings) + + rand.Read(data) + compressedB = CompressWithOption(data, 9) + dataRateSavings = 100 * (1.0 - float64(len(compressedB))/float64(len(data))) + fmt.Printf("random, Level 9: %2.0f%% percent space savings\n", dataRateSavings) + } diff --git a/src/crypt/crypt_test.go b/src/crypt/crypt_test.go index 29d891e5..23786018 100644 --- a/src/crypt/crypt_test.go +++ b/src/crypt/crypt_test.go @@ -30,4 +30,17 @@ func TestEncryption(t *testing.T) { dec, err := jane.Decrypt(enc) assert.Nil(t, err) assert.Equal(t, dec, []byte("hello, world")) + + jane2, err := New([]byte("password"), nil) + assert.Nil(t, err) + dec, err = jane2.Decrypt(enc) + assert.NotNil(t, err) + assert.NotEqual(t, dec, []byte("hello, world")) + + jane3, err := New([]byte("passwordwrong"), bob.Salt()) + assert.Nil(t, err) + dec, err = jane3.Decrypt(enc) + assert.NotNil(t, err) + assert.NotEqual(t, dec, []byte("hello, world")) + }