File: cons_test.go

package info (click to toggle)
golang-github-twstrike-otr3 0.0~git20161015.0.744856d-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,008 kB
  • ctags: 1,863
  • sloc: ansic: 127; makefile: 76
file content (37 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download | duplicates (3)
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)
}