test: restructure test packages

Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
Steffen Vogel
2022-08-31 14:21:54 +02:00
parent 82ca0f4146
commit ef8be95fcc
52 changed files with 227 additions and 105 deletions

46
test/test_test.go Normal file
View 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))
})
})