当前位置: 首页>>代码示例>>Golang>>正文


Golang C.Assert方法代码示例

本文整理汇总了Golang中github.com/twstrike/coyim/Godeps/_workspace/src/gopkg/in/check/v1.C.Assert方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Assert方法的具体用法?Golang C.Assert怎么用?Golang C.Assert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/twstrike/coyim/Godeps/_workspace/src/gopkg/in/check/v1.C的用法示例。


在下文中一共展示了C.Assert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Test_Peers_sortsByNameForPresentation

func (s *ListSuite) Test_Peers_sortsByNameForPresentation(c *g.C) {
	expectedPeers := []*Peer{
		&Peer{
			Jid: "ba", Name: "ab",
		},
		&Peer{
			Jid: "ac", Name: "",
		},
		&Peer{
			Jid: "aa", Name: "bb",
		},
		&Peer{
			Jid: "aa", Name: "cb",
		},
	}

	group := &Group{
		peers: []*Peer{
			expectedPeers[2],
			expectedPeers[0],
			expectedPeers[3],
			expectedPeers[1],
		},
	}

	c.Assert(group.Peers(), g.DeepEquals, expectedPeers)
}
开发者ID:rosatolen,项目名称:coyim,代码行数:27,代码来源:list_test.go

示例2: Test_LatestError_setsLatestErrorWhenExists

func (s *ListSuite) Test_LatestError_setsLatestErrorWhenExists(c *g.C) {
	l := New()
	pp := &Peer{Jid: "[email protected]"}
	l.AddOrMerge(pp)
	l.LatestError("[email protected]/foo", "tow", "frou", "sxi")

	c.Assert(pp.LatestError, g.DeepEquals, &PeerError{"tow", "frou", "sxi"})
}
开发者ID:rosatolen,项目名称:coyim,代码行数:8,代码来源:list_test.go

示例3: Test_Clear_clearsTheList

func (s *ListSuite) Test_Clear_clearsTheList(c *g.C) {
	l := New()
	l.AddOrMerge(&Peer{Jid: "[email protected]"})

	l.Clear()

	c.Assert(len(l.peers), g.Equals, 0)
}
开发者ID:rosatolen,项目名称:coyim,代码行数:8,代码来源:list_test.go

示例4: Test_SetLatestError_setsLatestError

func (s *PeerXmppSuite) Test_SetLatestError_setsLatestError(c *g.C) {
	p1 := &Peer{
		Groups:    toSet("one"),
		resources: toSet(),
	}
	p1.SetLatestError("oen", "tow", "there")

	c.Assert(p1.LatestError, g.DeepEquals, &PeerError{"oen", "tow", "there"})
}
开发者ID:rosatolen,项目名称:coyim,代码行数:9,代码来源:peer_test.go

示例5: Test_MergeWith_takesTheFirstGroupsIfExists

func (s *PeerXmppSuite) Test_MergeWith_takesTheFirstGroupsIfExists(c *g.C) {
	p1 := &Peer{
		Groups:    toSet("one"),
		resources: toSet(),
	}
	p2 := &Peer{}

	c.Assert(fromSet(p1.MergeWith(p2).Groups)[0], g.Equals, "one")
}
开发者ID:rosatolen,项目名称:coyim,代码行数:9,代码来源:peer_test.go

示例6: Test_SubscribeRequest_addsTheSubscribeID

func (s *ListSuite) Test_SubscribeRequest_addsTheSubscribeID(c *g.C) {
	l := New()
	l.AddOrMerge(&Peer{Jid: "[email protected]"})

	l.SubscribeRequest("[email protected]/hmm", "something", "")
	c.Assert(l.peers["[email protected]"].PendingSubscribeID, g.Equals, "something")

	l.SubscribeRequest("[email protected]/hmm2", "something3", "")
	c.Assert(l.peers["[email protected]"].PendingSubscribeID, g.Equals, "something3")
}
开发者ID:rosatolen,项目名称:coyim,代码行数:10,代码来源:list_test.go

示例7: Test_Dump_willDumpAllInfo

func (s *PeerXmppSuite) Test_Dump_willDumpAllInfo(c *g.C) {
	p := &Peer{
		Jid:          "[email protected]",
		Name:         "something",
		Subscription: "from",
		Groups:       toSet("hello::bar"),
		resources:    toSet(),
	}

	c.Assert(p.Dump(), g.Equals, "Peer{[email protected][something ()], subscription='from', status=''('') online=false, asked=false, pendingSubscribe='', belongsTo=''}")
}
开发者ID:rosatolen,项目名称:coyim,代码行数:11,代码来源:peer_test.go

示例8: Test_ToSlice_createsASliceOfTheContentSortedAlphabetically

func (s *ListSuite) Test_ToSlice_createsASliceOfTheContentSortedAlphabetically(c *g.C) {
	l := New()
	l.AddOrMerge(&Peer{Jid: "[email protected]"})
	l.AddOrMerge(&Peer{Jid: "[email protected]"})
	l.AddOrMerge(&Peer{Jid: "[email protected]"})

	c.Assert(l.ToSlice(), g.DeepEquals, []*Peer{
		&Peer{Jid: "[email protected]"},
		&Peer{Jid: "[email protected]"},
		&Peer{Jid: "[email protected]"},
	})
}
开发者ID:rosatolen,项目名称:coyim,代码行数:12,代码来源:list_test.go

示例9: Test_PeerWithState_createsANewPeer

func (s *PeerXmppSuite) Test_PeerWithState_createsANewPeer(c *g.C) {
	p := PeerWithState("[email protected]/1234", "hmm", "no", "", "")
	c.Assert(p.Jid, g.Equals, "[email protected]")
	c.Assert(p.Name, g.Equals, "")
	c.Assert(p.Status, g.Equals, "hmm")
	c.Assert(p.StatusMsg, g.Equals, "no")
}
开发者ID:rosatolen,项目名称:coyim,代码行数:7,代码来源:peer_test.go

示例10: Test_IterAll_willIterateOverAllTheListsGivenAndYieldTheirPeers

func (s *ListSuite) Test_IterAll_willIterateOverAllTheListsGivenAndYieldTheirPeers(c *g.C) {
	l := New()
	l2 := New()
	pp := &Peer{Jid: "[email protected]"}
	pp2 := &Peer{Jid: "[email protected]"}
	l.AddOrMerge(pp)
	l2.AddOrMerge(pp2)

	result := []*Peer{}
	IterAll(func(_ int, p *Peer) {
		result = append(result, p)
	}, l, l2)

	c.Assert(result, g.DeepEquals, []*Peer{pp2, pp})
}
开发者ID:rosatolen,项目名称:coyim,代码行数:15,代码来源:list_test.go

示例11: Test_GetPendingSubscribe_returnsThePendingSubscribeIfExists

func (s *ListSuite) Test_GetPendingSubscribe_returnsThePendingSubscribeIfExists(c *g.C) {
	l := New()
	l.AddOrMerge(&Peer{Jid: "[email protected]", PendingSubscribeID: "foo"})
	l.AddOrMerge(&Peer{Jid: "[email protected]"})

	v, k := l.GetPendingSubscribe("[email protected]")
	c.Assert(k, g.Equals, false)

	v, k = l.GetPendingSubscribe("[email protected]/bar")
	c.Assert(k, g.Equals, true)
	c.Assert(v, g.Equals, "foo")

	v, k = l.GetPendingSubscribe("[email protected]/bar")
	c.Assert(k, g.Equals, false)
	c.Assert(v, g.Equals, "")
}
开发者ID:rosatolen,项目名称:coyim,代码行数:16,代码来源:list_test.go

示例12: Test_Unsubscribed_whenExist

func (s *ListSuite) Test_Unsubscribed_whenExist(c *g.C) {
	l := New()
	l.AddOrMerge(&Peer{Jid: "[email protected]", Subscription: "both", Asked: true, PendingSubscribeID: "foo"})
	l.AddOrMerge(&Peer{Jid: "[email protected]", Subscription: "to"})
	l.AddOrMerge(&Peer{Jid: "foo3[email protected]", Subscription: "from"})

	l.Unsubscribed("[email protected]/123")
	c.Assert(l.peers["[email protected]"].Subscription, g.Equals, "from")
	c.Assert(l.peers["[email protected]"].Asked, g.Equals, false)
	c.Assert(l.peers["[email protected]"].PendingSubscribeID, g.Equals, "")

	l.Unsubscribed("[email protected]/123")
	c.Assert(l.peers["[email protected]"].Subscription, g.Equals, "none")

	l.Unsubscribed("[email protected]/123")
	c.Assert(l.peers["[email protected]"].Subscription, g.Equals, "from")
}
开发者ID:rosatolen,项目名称:coyim,代码行数:17,代码来源:list_test.go

示例13: Test_toEntry_ReturnsAnEntryWithTheInformation

func (s *PeerXmppSuite) Test_toEntry_ReturnsAnEntryWithTheInformation(c *g.C) {
	p := &Peer{
		Jid:          "[email protected]",
		Name:         "something",
		Subscription: "from",
		Groups:       toSet("hello::bar"),
		resources:    toSet(),
	}

	c.Assert(p.ToEntry().Jid, g.Equals, "[email protected]")
	c.Assert(p.ToEntry().Name, g.Equals, "something")
	c.Assert(p.ToEntry().Subscription, g.Equals, "from")
	c.Assert(p.ToEntry().Group, g.DeepEquals, []string{"hello::bar"})
}
开发者ID:rosatolen,项目名称:coyim,代码行数:14,代码来源:peer_test.go

示例14: Test_Remove_doesNothingWhenAskedToRemoveEntryNotInList

func (s *ListSuite) Test_Remove_doesNothingWhenAskedToRemoveEntryNotInList(c *g.C) {
	l := New()
	l.peers["[email protected]"] = &Peer{}

	res, rem := l.Remove("[email protected]")

	c.Assert(rem, g.Equals, false)
	c.Assert(res, g.IsNil)
	c.Assert(len(l.peers), g.Equals, 1)
}
开发者ID:rosatolen,项目名称:coyim,代码行数:10,代码来源:list_test.go

示例15: Test_AddOrMerge_addsTheEntryIfNotInTheList

func (s *ListSuite) Test_AddOrMerge_addsTheEntryIfNotInTheList(c *g.C) {
	l := New()
	p := &Peer{Jid: "somewhere", Name: "something"}

	res := l.AddOrMerge(p)

	c.Assert(res, g.Equals, true)
	c.Assert(len(l.peers), g.Equals, 1)
	c.Assert(l.peers["somewhere"], g.Equals, p)
}
开发者ID:rosatolen,项目名称:coyim,代码行数:10,代码来源:list_test.go


注:本文中的github.com/twstrike/coyim/Godeps/_workspace/src/gopkg/in/check/v1.C.Assert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。