1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package sexp
import (
"bufio"
"bytes"
"testing"
)
func Test_Cons_First_ReturnsTheFirstElement(t *testing.T) {
c := Cons{Sstring("First"), Sstring("Second")}
assertEquals(t, c.First(), Sstring("First"))
}
func Test_Cons_Second_ReturnsTheSecondElement(t *testing.T) {
c := Cons{Sstring("First"), Sstring("Second")}
assertEquals(t, c.Second(), Sstring("Second"))
}
func Test_Cons_Value_ReturnsTheFirstElement(t *testing.T) {
c := Cons{Sstring("First"), Sstring("Second")}
assertEquals(t, c.Value(), Sstring("First"))
}
func Test_Cons_String_ReturnsTheConsFormatted(t *testing.T) {
c := Cons{Sstring("First"), Sstring("Second")}
assertEquals(t, c.String(), "(\"First\" . \"Second\")")
}
func Test_ReadList_returnsNilIfAskedToReadNonList(t *testing.T) {
res := ReadList(bufio.NewReader(bytes.NewReader([]byte("a"))))
assertEquals(t, res, nil)
}
func Test_ReadList_returnsNilIfAskedToReadListThatDoesntEndWell(t *testing.T) {
res := ReadList(bufio.NewReader(bytes.NewReader([]byte("("))))
assertEquals(t, res, nil)
}
|