mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-11-03 13:00:50 +08:00
test: restructure test packages
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
46
test/test_test.go
Normal file
46
test/test_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package test_test
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"riasc.eu/wice/test"
|
||||
)
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Test Helper Suite")
|
||||
}
|
||||
|
||||
var _ = test.SetupLogging()
|
||||
|
||||
var _ = Describe("entropy", func() {
|
||||
Specify("that the entropy of an empty slice is zero", func() {
|
||||
Expect(test.Entropy([]byte{})).To(BeNumerically("==", 0))
|
||||
Expect(test.Entropy(nil)).To(BeNumerically("==", 0))
|
||||
})
|
||||
|
||||
Specify("that the entropy of A is defined as", func() {
|
||||
Expect(test.Entropy([]byte("AAAAAAAAAAAAAA"))).To(BeZero())
|
||||
})
|
||||
|
||||
Specify("that the entropy of A is defined as", func() {
|
||||
Expect(test.Entropy([]byte("This is some not-so random string"))).To(
|
||||
And(
|
||||
BeNumerically(">", 1),
|
||||
BeNumerically("<", 5),
|
||||
),
|
||||
)
|
||||
})
|
||||
|
||||
Specify("that the entropy of random data", func() {
|
||||
random := make([]byte, 128)
|
||||
n, err := rand.Read(random)
|
||||
Expect(err).To(Succeed())
|
||||
Expect(n).To(Equal(128))
|
||||
|
||||
Expect(test.Entropy(random)).To(BeNumerically(">", 5))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user