test coverage only by PBT
All checks were successful
Go / test (push) Successful in 13s

This commit is contained in:
Adam Jeniski 2025-11-04 15:11:24 -10:00
parent 5ac5acd6d1
commit ec10d85591

View File

@ -6,39 +6,39 @@ import (
"testing" "testing"
) )
func TestListLen(t *testing.T) { // func TestListLen(t *testing.T) {
assert.Equal(t, 0, Empty().Len(), "should insert at head") // assert.Equal(t, 0, Empty().Len(), "should insert at head")
assert.Equal(t, 1, Empty().Conj(1).Len(), "should insert at head") // assert.Equal(t, 1, Empty().Conj(1).Len(), "should insert at head")
assert.Equal(t, 2, Empty().Conj(1).Conj(2).Len(), "should insert at head") // assert.Equal(t, 2, Empty().Conj(1).Conj(2).Len(), "should insert at head")
} // }
//
func TestListString(t *testing.T) { // func TestListString(t *testing.T) {
assert.Equal(t, "()", Empty().String(), "should insert at head") // assert.Equal(t, "()", Empty().String(), "should insert at head")
} // }
//
func TestListConj(t *testing.T) { // func TestListConj(t *testing.T) {
var l IList // var l IList
assert.Equal(t, "()", Empty().String(), "should insert at head") // assert.Equal(t, "()", Empty().String(), "should insert at head")
l = New(5) // l = New(5)
assert.Equal(t, "(5)", l.String(), "should insert at head") // assert.Equal(t, "(5)", l.String(), "should insert at head")
l = Empty().Conj(4) // l = Empty().Conj(4)
assert.Equal(t, "(4)", l.String(), "should insert at head") // assert.Equal(t, "(4)", l.String(), "should insert at head")
} // }
//
func TestListFirst(t *testing.T) { // func TestListFirst(t *testing.T) {
l := Empty().Conj(5).Conj(6).Conj(7) // l := Empty().Conj(5).Conj(6).Conj(7)
assert.Equal(t, 7, l.First(), "should return first element") // assert.Equal(t, 7, l.First(), "should return first element")
assert.Equal(t, nil, Empty().First(), "should return nil") // assert.Equal(t, nil, Empty().First(), "should return nil")
} // }
//
func TestListRest(t *testing.T) { // func TestListRest(t *testing.T) {
l := Empty().Conj(5).Conj(6).Conj(7) // l := Empty().Conj(5).Conj(6).Conj(7)
assert.Equal(t, "(6 5)", l.Rest().String(), "should return rest sublist") // assert.Equal(t, "(6 5)", l.Rest().String(), "should return rest sublist")
assert.Equal(t, "(5)", l.Rest().Rest().String(), "should return rest sublist") // assert.Equal(t, "(5)", l.Rest().Rest().String(), "should return rest sublist")
assert.Equal(t, "()", l.Rest().Rest().Rest().String(), "should return rest sublist") // assert.Equal(t, "()", l.Rest().Rest().Rest().String(), "should return rest sublist")
assert.Equal(t, Empty(), Empty().Rest(), "should return rest sublist") // assert.Equal(t, Empty(), Empty().Rest(), "should return rest sublist")
assert.Equal(t, Empty(), Empty().Rest().Rest(), "should return rest sublist") // assert.Equal(t, Empty(), Empty().Rest().Rest(), "should return rest sublist")
} // }
// generative tests // generative tests
func ListLengthProperty(t *testing.T) { func ListLengthProperty(t *testing.T) {
@ -56,6 +56,10 @@ func ListLengthProperty(t *testing.T) {
} }
myList = myList.Rest() myList = myList.Rest()
}, },
"stringify": func(t *rapid.T) {
myList.String()
},
"": func(t *rapid.T) { "": func(t *rapid.T) {
assert.Equal(t, myList.Len(), expectedSized, "must be equal") assert.Equal(t, myList.Len(), expectedSized, "must be equal")
}, },