當前位置: 首頁>>代碼示例>>Golang>>正文


Golang e.Equal函數代碼示例

本文整理匯總了Golang中github.com/fcavani/e.Equal函數的典型用法代碼示例。如果您正苦於以下問題:Golang Equal函數的具體用法?Golang Equal怎麽用?Golang Equal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Equal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestClose

func TestClose(t *testing.T) {
	err := c.Close()
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = connPool.Close("1", "0")
	if err != nil && !e.Equal(err, ErrSessNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = connPool.Close("0", "1")
	if err != nil && !e.Equal(err, ErrInstNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = connPool.Close("0", "0")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = p.Close()
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = server.Close()
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:26,代碼來源:clone_test.go

示例2: TestDB

func TestDB(t *testing.T) {
	err := CreateDB(couchUrl, dbName)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	defer DeleteDB(couchUrl, dbName)

	err = CreateDB(couchUrl, dbName)
	if err != nil && !e.Equal(err, ErrDbExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	info, err := InfoDB(couchUrl, dbName)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	if info.Db_name != dbName || info.Doc_count != 0 {
		t.Fatal("samething wrong with the db")
	}

	err = DeleteDB(couchUrl, dbName)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	_, err = InfoDB(couchUrl, dbName)
	if err != nil && !e.Equal(err, ErrDbNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	err = DeleteDB(couchUrl, dbName)
	if err != nil && !e.Equal(err, ErrDbNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:monlite,代碼行數:35,代碼來源:couch_test.go

示例3: TestInitClones

func TestInitClones(t *testing.T) {
	connPool = &clones{
		Num:    1,
		MaxNum: 5,
	}
	err := connPool.Init()
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	connPoolErr := &clones{
		Num:    0,
		MaxNum: 5,
	}
	err = connPoolErr.Init()
	if err != nil && !e.Equal(err, "number of clones invalid") {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("nil error")
	}

	connPoolErr = &clones{
		Num:    10,
		MaxNum: 5,
	}
	err = connPoolErr.Init()
	if err != nil && !e.Equal(err, "number of streams is greater than max") {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("nil error")
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:32,代碼來源:clone_test.go

示例4: TestNewNoValueInstance

func TestNewNoValueInstance(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	ownersWrong := auth.NewPlainTextCredentials()
	err = ownersWrong.Add(&auth.PlainText{"id2", "passssss"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	err = instances.NewNoValueInstance("1", "321", owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.NewNoValueInstance("1", "111", ownersWrong)
	if err != nil && !e.Equal(err, ErrOwnerNotMatch) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	err = instances.NewNoValueInstance("123", "1", owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.NewNoValueInstance("123", "1", owners)
	if err != nil && !e.Equal(err, ErrInstExists) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:33,代碼來源:instances_test.go

示例5: TestGet

func TestGet(t *testing.T) {
	inst, err := instances.Get("1", "1")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	if inst.Instance().Type() != reflect.TypeOf(&teststruct{}) {
		t.Fatal("get fail")
	}

	inst, err = instances.Get("1", "3")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	if inst.Instance().Type() != reflect.TypeOf(&teststruct{}) {
		t.Fatal("get fail")
	}

	_, err = instances.Get("1", "1")
	if err != nil && !e.Equal(err, ErrAuthUserNotAuthorized) {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	_, err = instances.Get("2", "2")
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = instances.Get("1", "2")
	if err != nil && !e.Equal(err, ErrInstanceNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:31,代碼來源:instances_test.go

示例6: TestAuthSession

func TestAuthSession(t *testing.T) {
	a := &auth.PlainText{"id3", "pass6969"}
	err := instances.AuthSession("sess", a)
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}

	err = instances.AuthSession("1", a)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	err = instances.AuthSession("1", &auth.PlainText{"id3", "pass69222269"})
	if err != nil && !e.Equal(err, ErrAuthUserNotAuthorized) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}
	err = instances.AuthSession("1", &auth.PlainText{"id4", "pass69222269"})
	if err != nil && !e.Equal(err, ErrAuthUserNotAuthorized) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:27,代碼來源:instances_test.go

示例7: TestConstructFail

func TestConstructFail(t *testing.T) {
	err := constructor.New(&struct3{}, func(count int) int {
		return 42
	})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = constructor.Construct(types.Name(&struct3{}), 0)
	if err != nil && !e.Equal(err, ErrInvReturn) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}

	err = constructor.Delete(types.Name(&struct3{}))
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	err = constructor.New(&struct3{}, func(count int) (int, int) {
		return 42, 69
	})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = constructor.Construct(types.Name(&struct3{}), 0)
	if err != nil && !e.Equal(err, ErrInvReturn) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:32,代碼來源:constructor_test.go

示例8: TestDeletePlainTextCredentials

func TestDeletePlainTextCredentials(t *testing.T) {
	ptc := NewPlainTextCredentials()

	pt1 := &PlainText{"id", "pass1234"}

	err := ptc.Add(pt1)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = ptc.Get("id")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = ptc.Delete("id")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = ptc.Delete("id")
	if err != nil && !e.Equal(err, ErrCredNotExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = ptc.Get("id")
	if err != nil && !e.Equal(err, ErrCredNotExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:26,代碼來源:auth_test.go

示例9: TestAddPlainTextCredentials

func TestAddPlainTextCredentials(t *testing.T) {
	ptc := NewPlainTextCredentials()

	pt1 := &PlainText{"id", "pass1234"}
	pt1b := &PlainText{"id", "pass1234"}
	pt2 := &PlainText{"id2", "pass2345"}
	hash := &Hashed{"a", "b"}

	err := ptc.Add(pt1)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = ptc.Add(pt2)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = ptc.Add(pt1b)
	if err != nil && !e.Equal(err, ErrCredExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = ptc.Add(hash)
	if err != nil && !e.Equal(err, ErrNotComp) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:25,代碼來源:auth_test.go

示例10: TestDelete

func TestDelete(t *testing.T) {
	err := instances.Delete("1", "3")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.Delete("1", "3")
	if err != nil && !e.Equal(err, ErrInstanceNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.Delete("2", "3")
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:14,代碼來源:instances_test.go

示例11: TestClonesReturnFail

func TestClonesReturnFail(t *testing.T) {
	conn, err := connPool.Request(p, "0")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = connPool.Return("1", "0", conn)
	if err != nil && !e.Equal(err, ErrSessNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = connPool.Return("0", "1", conn)
	if err != nil && !e.Equal(err, ErrInstNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:14,代碼來源:clone_test.go

示例12: TestInit

func TestInit(t *testing.T) {
	var err error
	p, err = openSession("tcp", server.Address().String(), nil, "0", id, time.Second, 0)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	c = &clone{
		Num:     1,
		MaxNum:  5,
		Session: p,
	}
	err = c.Init("0")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	cerr := &clone{
		Num:     5,
		MaxNum:  1,
		Session: p,
	}
	err = cerr.Init("0")
	if err != nil && !e.Equal(err, "number of initial streams is greater than the maximun") {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("nil error")
	}
	cerr = &clone{
		Num:     0,
		MaxNum:  1,
		Session: p,
	}
	err = cerr.Init("0")
	if err != nil && !e.Equal(err, "number of clones invalid") {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("nil error")
	}
	cerr = &clone{
		Num:     1,
		MaxNum:  3,
		Session: nil,
	}
	err = cerr.Init("0")
	if err != nil && !e.Equal(err, "nil Session") {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("nil error")
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:50,代碼來源:clone_test.go

示例13: TestExportGet

func TestExportGet(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("sess", "testexport", reflect.ValueOf(&TestExport{}), owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.Export("sess", "testexport", &ToExport{
		Method:    "TestRetval",
		RetvalPos: 0,
		Export: &Export{
			Client: &TestExportClient{},
		},
	})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = instances.ExportGet("sess", "testexport", "TestRetval", 0)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = instances.ExportGet("invalid sess", "testexport", "TestRetval", 0)
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	_, err = instances.ExportGet("sess", "testexport__", "TestRetval", 0)
	if err != nil && !e.Equal(err, ErrInstanceNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	_, err = instances.ExportGet("sess", "testexport", "TestRetval__", 0)
	if err != nil && !e.Equal(err, ErrMethodNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	_, err = instances.ExportGet("sess", "testexport", "TestRetval", 999)
	if err != nil && !e.Equal(err, ErrReturnValueNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:49,代碼來源:instances_test.go

示例14: TestPurge

func TestPurge(t *testing.T) {
	instances.PurgeAll()
	_, err := instances.Get("1", "1")
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:7,代碼來源:instances_test.go

示例15: TestEditPlainTextCredentials

func TestEditPlainTextCredentials(t *testing.T) {
	ptc := NewPlainTextCredentials()

	pt1 := &PlainText{"id", "pass1234"}

	err := ptc.Add(pt1)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	pt1b := &PlainText{"id", "pass2345"}

	err = ptc.Edit(pt1b)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	auth, err := ptc.Get("id")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	if !auth.Auth(pt1b) {
		t.Fatal("auth not equal")
	}

	pt2 := &PlainText{"id2", "pass2345"}
	err = ptc.Edit(pt2)
	if err != nil && !e.Equal(err, ErrCredNotExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
}
開發者ID:fcavani,項目名稱:gormethods,代碼行數:30,代碼來源:auth_test.go


注:本文中的github.com/fcavani/e.Equal函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。