package cli

import (
	"reflect"
	"sync"
	"testing"
)

func TestContext_Bind(t *testing.T) {
	type fields struct {
		ID       int32
		CmdStr   string
		Args     []string
		locker   sync.RWMutex
		Values   map[string]interface{}
		response *Response
	}
	type args struct {
		i interface{}
	}
	tests := []struct {
		name    string
		fields  fields
		args    args
		wantErr bool
	}{
		// TODO: Add test cases.
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ctx := &Context{
				ID:       tt.fields.ID,
				CmdStr:   tt.fields.CmdStr,
				Args:     tt.fields.Args,
				locker:   tt.fields.locker,
				Values:   tt.fields.Values,
				response: tt.fields.response,
			}
			if err := ctx.Bind(tt.args.i); (err != nil) != tt.wantErr {
				t.Errorf("Bind() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}

func TestContext_Error(t *testing.T) {
	type fields struct {
		ID       int32
		CmdStr   string
		Args     []string
		locker   sync.RWMutex
		Values   map[string]interface{}
		response *Response
	}
	type args struct {
		code int
		msg  string
	}
	tests := []struct {
		name    string
		fields  fields
		args    args
		wantErr bool
	}{
		// TODO: Add test cases.
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ctx := &Context{
				ID:       tt.fields.ID,
				CmdStr:   tt.fields.CmdStr,
				Args:     tt.fields.Args,
				locker:   tt.fields.locker,
				Values:   tt.fields.Values,
				response: tt.fields.response,
			}
			if err := ctx.Error(tt.args.code, tt.args.msg); (err != nil) != tt.wantErr {
				t.Errorf("Error() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}


func TestContext_Success(t *testing.T) {
	type fields struct {
		ID       int32
		CmdStr   string
		Args     []string
		locker   sync.RWMutex
		Values   map[string]interface{}
		response *Response
	}
	type args struct {
		i interface{}
	}
	tests := []struct {
		name    string
		fields  fields
		args    args
		wantErr bool
	}{
		// TODO: Add test cases.
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ctx := &Context{
				ID:       tt.fields.ID,
				CmdStr:   tt.fields.CmdStr,
				Args:     tt.fields.Args,
				locker:   tt.fields.locker,
				Values:   tt.fields.Values,
				response: tt.fields.response,
			}
			if err := ctx.Success(tt.args.i); (err != nil) != tt.wantErr {
				t.Errorf("Success() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}

func TestRef(t *testing.T)  {
	type x struct {
		A string
	}
	refVal := reflect.Indirect(reflect.ValueOf(&x{A: "xxx"}))
	t.Log(refVal.Field(0).Kind())
	t.Log(refVal.Type().Field(0).Name)
}