Exemplo n.º 1
0
func init() {
	types.Insert(True{})
	types.Insert(False{})
	types.Insert(If{})
	gob.Register(True{})
	gob.Register(False{})
	gob.Register(If{})
}
Exemplo n.º 2
0
func init() {
	gob.Register(&TestExportClient{})
	types.Insert(&TestExportClient{})
}
Exemplo n.º 3
0
func init() {
	gob.Register(&ResultClient{})
	types.Insert(&ResultClient{})
}
Exemplo n.º 4
0
func init() {
	types.Insert(&Error{})
	gob.Register(&Error{})
}
Exemplo n.º 5
0
func TestRegisterPhoto(t *testing.T) {
	types.Insert(&photo{})
}
Exemplo n.º 6
0
func init() {
	types.Insert(&reqCall{})
}
Exemplo n.º 7
0
Arquivo: tags.go Projeto: fcavani/tags
func init() {
	types.Insert(&Tags{})
}
Exemplo n.º 8
0
func init() {
	gob.Register(&status{})
	types.Insert(&status{})
}
Exemplo n.º 9
0
func init() {
	gob.Register(&log{})
	types.Insert(&log{})
}
Exemplo n.º 10
0
func init() {
	gob.Register(&Disk{})
	gob.Register(&Process{})
	types.Insert(&Disk{})
	types.Insert(&Process{})
}
Exemplo n.º 11
0
func init() {
	types.Insert(&markedImage{})
}
Exemplo n.º 12
0
func init() {
	types.Insert(Calculator{})
}
Exemplo n.º 13
0
func init() {
	types.Insert(foo(""))
}
Exemplo n.º 14
0
func init() {
	types.Insert(&Time{})
	types.Insert(&timehold{})
	types.Insert(timehold{})
}
Exemplo n.º 15
0
func init() {
	gob.Register(&TestChannelClient{})
	types.Insert(&TestChannelClient{})
}
Exemplo n.º 16
0
func init() {
	types.Insert(&ChannelDescriptor{})
}
Exemplo n.º 17
0
func init() {
	gob.Register(&CacheClient{})
	types.Insert(&CacheClient{})
}
Exemplo n.º 18
0
func init() {
	types.Insert(&TestStruct{})
}
Exemplo n.º 19
0
func init() {
	types.Insert(&PlainText{})
	types.Insert(&Hashed{})
}
Exemplo n.º 20
0
func TestReqCall(t *testing.T) {
	var nilstruct *reqCall
	var err error
	str := "string"
	//var inil interface{} = nilstruct
	var istr interface{} = str
	var ipstr interface{} = &str
	emptySlice := make([]int, 0)
	types.Insert(make([]int, 0))
	s := &strct{}
	types.Insert(s)
	tests := []*reqCall{
		{"", nil},
		{"oi", []reflect.Value{}},
		{"oi", []reflect.Value{reflect.ValueOf(nilstruct)}},
		{"oi", []reflect.Value{reflect.ValueOf(err)}},
		{"oi", []reflect.Value{reflect.ValueOf(e.New("oi"))}},
		{"oi", []reflect.Value{reflect.ValueOf(errors.New("oi"))}},
		{"oi", []reflect.Value{reflect.ValueOf(1)}},
		{"oi", []reflect.Value{reflect.ValueOf("string")}},
		//{"oi", []reflect.Value{reflect.ValueOf(&str)}},
		//{"oi", []reflect.Value{reflect.ValueOf(inil)}},
		{"oi", []reflect.Value{reflect.ValueOf(istr)}},
		{"oi", []reflect.Value{reflect.ValueOf(ipstr)}},
		{"oi", []reflect.Value{reflect.ValueOf(s)}},
		{"oi", []reflect.Value{reflect.ValueOf(emptySlice)}},
	}

	for i, test := range tests {
		buf := bytes.NewBuffer([]byte{})
		enc := msgpack.NewEncoder(buf)
		dec := msgpack.NewDecoder(buf)
		err := enc.Encode(test)
		if err != nil {
			t.Fatal(i, e.Trace(e.Forward(err)))
		}
		var req reqCall
		err = dec.Decode(&req)
		if err != nil {
			t.Fatal(i, e.Trace(e.Forward(err)))
		}
		if req.Method != test.Method {
			t.Fatal("method not equal")
		}
		if len(req.Args) != len(test.Args) {
			t.Fatal("num of args not equal")
		}
		for ii, arg := range req.Args {
			if zero.IsZero(arg) != zero.IsZero(test.Args[ii]) {
				t.Fatal("arg differ", i, ii, zero.IsZero(arg), zero.IsZero(test.Args[ii]))
			}
			if zero.IsZero(arg) {
				continue
			}

			if arg.IsValid() != test.Args[ii].IsValid() {
				t.Fatal("valid differ")
			}
			if !arg.IsValid() {
				continue
			}

			if test.Args[ii].Kind() == reflect.Interface || test.Args[ii].Kind() == reflect.Map || test.Args[ii].Kind() == reflect.Ptr || test.Args[ii].Kind() == reflect.Slice {
				if arg.IsNil() != test.Args[ii].IsNil() {
					t.Fatal("arg differ", i, arg.IsNil(), test.Args[ii].IsNil())
				}
				if arg.IsNil() {
					continue
				}
			}
			if _, ok := arg.Interface().(*e.Error); !ok && !reflect.DeepEqual(arg.Interface(), test.Args[ii].Interface()) {
				t.Fatalf("Fail to encode and decode %v %#v %#v", i, arg.Interface(), test.Args[ii].Interface())
			}
		}
	}
}
Exemplo n.º 21
0
func init() {
	types.Insert(Calc{})
}