Beispiel #1
0
func Test_decodeBEInt(t0 *testing.T) {
	t := testingo.T(t0)

	data := []byte{0, 0, 0, 0}
	t.AssertEq(0, decodeBEInt(data), data)
	data = []byte{0, 0, 0, 255}
	t.AssertEq(255, decodeBEInt(data), data)
	data = []byte{1, 0, 0, 0}
	t.AssertEq((1 << 24), decodeBEInt(data), data)
}
Beispiel #2
0
func Test_connectAndQuery(t0 *testing.T) {
	t := testingo.T(t0)

	c, err := NewPGConnection(`tcp://localhost:5432?user=postgres&debugName=pgfsm`, nil, 2*time.Second)

	t.AssertNotEq(nil, c)
	t.AssertEq(nil, err)

	result := c.Query("SELECT * FROM information_schema.parameters")
	t.AssertEq(nil, result)
}
Beispiel #3
0
func TestFSM(t0 *testing.T) {
	t := testingo.T(t0)

	ch := make(chan interface{})
	oldTemplate := templateFSM

	fsm := myFSM.New(3, t)
	fsm.Send(4) // Init -> A
	fsm.Send(3) // A -> B
	fsm.Send(9) // B -> C
	fsm.Go(ch)
	fsm.Send(10)         // C -> A
	fsm.SendAllStates(5) // A -> Event -> A
	fsm.Send(4)          // A -> B
	fsm.Terminate()
	t.AssertEq(templateFSM, oldTemplate)
}