예제 #1
0
파일: zmq4_test.go 프로젝트: rdterner/zmq4
func Example_test_ctx_options() {

	i, err := zmq.GetMaxSockets()
	fmt.Println(i == zmq.MaxSocketsDflt, err)
	i, err = zmq.GetIoThreads()
	fmt.Println(i == zmq.IoThreadsDflt, err)
	b, err := zmq.GetIpv6()
	fmt.Println(b, err)

	zmq.SetIpv6(true)
	b, err = zmq.GetIpv6()
	fmt.Println(b, err)

	router, _ := zmq.NewSocket(zmq.ROUTER)
	b, err = router.GetIpv6()
	fmt.Println(b, err)

	fmt.Println(router.Close())

	zmq.SetIpv6(false)

	fmt.Println("Done")
	// Output:
	// true <nil>
	// true <nil>
	// false <nil>
	// true <nil>
	// true <nil>
	// <nil>
	// Done
}
예제 #2
0
파일: zmq4_test.go 프로젝트: pebbe/zmq4
func TestCtxOptions(t *testing.T) {

	type Result struct {
		value interface{}
		err   error
	}

	i, err := zmq.GetMaxSockets()
	if err != nil {
		t.Error("GetMaxSockets:", err)
	}
	if i != zmq.MaxSocketsDflt {
		t.Errorf("MaxSockets != MaxSocketsDflt: %d != %d", i, zmq.MaxSocketsDflt)
	}

	i, err = zmq.GetIoThreads()
	if err != nil {
		t.Error("GetIoThreads:", err)
	}
	if i != zmq.IoThreadsDflt {
		t.Errorf("IoThreads != IoThreadsDflt: %d != %d", i, zmq.IoThreadsDflt)
	}

	b, err := zmq.GetIpv6()
	if b != false || err != nil {
		t.Errorf("GetIpv6 1: expected false <nil>, got %v %v", b, err)
	}

	zmq.SetIpv6(true)
	defer zmq.SetIpv6(false)
	b, err = zmq.GetIpv6()
	if b != true || err != nil {
		t.Errorf("GetIpv6 2: expected true <nil>, got %v %v", b, err)
	}

	router, _ := zmq.NewSocket(zmq.ROUTER)
	b, err = router.GetIpv6()
	if b != true || err != nil {
		t.Errorf("GetIpv6 3: expected true <nil>, got %v %v", b, err)
	}
	router.Close()
}