mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
add more to tests
This commit is contained in:
parent
9030aae880
commit
376591384a
2 changed files with 25 additions and 0 deletions
|
@ -75,4 +75,16 @@ func TestCompress(t *testing.T) {
|
||||||
dataRateSavings = 100 * (1.0 - float64(len(compressedB))/float64(len(fable)))
|
dataRateSavings = 100 * (1.0 - float64(len(compressedB))/float64(len(fable)))
|
||||||
fmt.Printf("Level -2: %2.0f%% percent space savings\n", dataRateSavings)
|
fmt.Printf("Level -2: %2.0f%% percent space savings\n", dataRateSavings)
|
||||||
assert.True(t, len(compressedB) < len(fable))
|
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)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,17 @@ func TestEncryption(t *testing.T) {
|
||||||
dec, err := jane.Decrypt(enc)
|
dec, err := jane.Decrypt(enc)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, dec, []byte("hello, world"))
|
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"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue