add PBT for list len
All checks were successful
Go / test (push) Successful in 11s

This commit is contained in:
Adam Jeniski 2025-11-04 14:58:08 -10:00
parent c044f452b5
commit 413ab23904

View File

@ -40,19 +40,24 @@ func TestListRest(t *testing.T) {
assert.Equal(t, Empty(), Rest(Empty().Rest()), "should return rest sublist")
}
type listGen struct{}
// generative tests
func TestConjIncreasesLen(t *testing.T) {
l := Empty()
func ListLengthProperty(t *testing.T) {
myList := Empty()
expectedSized := 0
rapid.Check(t, func(t *rapid.T) {
t.Repeat(map[string]func(*rapid.T){
"conj": func(t *rapid.T) {
expectedSized += 0
expectedSized += 1
myList = myList.Conj(rapid.Int().Draw(t, "el"))
},
"rest": func(t *rapid.T) {
if !myList.IsEmpty() {
expectedSized -= 1
}
myList = myList.Rest()
},
"": func(t *rapid.T) {
assert.Equal(t, l.Len(), expectedSized, "must be equal")
assert.Equal(t, myList.Len(), expectedSized, "must be equal")
},
})
})