This commit is contained in:
parent
f816fdc912
commit
ca2485b725
@ -1,10 +1,15 @@
|
|||||||
package read
|
package read
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
"fmt"
|
||||||
|
"mal-go/hash_map"
|
||||||
"mal-go/list"
|
"mal-go/list"
|
||||||
"mal-go/symbol"
|
"mal-go/symbol"
|
||||||
|
"mal-go/vector"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"pgregory.net/rapid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReadInt(t *testing.T) {
|
func TestReadInt(t *testing.T) {
|
||||||
@ -47,3 +52,33 @@ func TestReadList(t *testing.T) {
|
|||||||
assert.Equal(t, nil, err, "should read without error")
|
assert.Equal(t, nil, err, "should read without error")
|
||||||
assert.Equal(t, len(input), pos, "should read the whole string")
|
assert.Equal(t, len(input), pos, "should read the whole string")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func StringifiedFormGen() *rapid.Generator[string] {
|
||||||
|
return rapid.OneOf(rapid.Custom(func(t *rapid.T) string {
|
||||||
|
myList := list.Empty()
|
||||||
|
i := 200
|
||||||
|
t.Repeat(map[string]func(*rapid.T){
|
||||||
|
"conj": func(t *rapid.T) {
|
||||||
|
if i < 50 {
|
||||||
|
myList = myList.Conj(StringifiedFormGen().Draw(t, "el"))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return myList.String()
|
||||||
|
}),
|
||||||
|
rapid.Just(list.Empty().String()),
|
||||||
|
rapid.Just(hash_map.New().String()),
|
||||||
|
rapid.Just(vector.New().String()),
|
||||||
|
rapid.Custom(func(t *rapid.T) string {
|
||||||
|
return fmt.Sprint(rapid.Int().Draw(t, "i"))
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRead(t *testing.T) {
|
||||||
|
rapid.Check(t, func(t *rapid.T) {
|
||||||
|
input := StringifiedFormGen().Draw(t, "input")
|
||||||
|
_, err, _ := readForm(input, 0, "user")
|
||||||
|
assert.Nil(t, err, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user