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


Golang assert.Equal函数代码示例

本文整理汇总了Golang中github.com/shilkin/centrifugo/Godeps/_workspace/src/github.com/stretchr/testify/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: TestClientMessage

func TestClientMessage(t *testing.T) {
	app := testApp()
	c, err := newClient(app, &testSession{})
	assert.Equal(t, nil, err)

	// empty message
	err = c.message([]byte{})
	assert.Equal(t, ErrInvalidMessage, err)

	// malformed message
	err = c.message([]byte("wroooong"))
	assert.NotEqual(t, nil, err)

	var cmds []clientCommand

	nonConnectFirstCmd := clientCommand{
		Method: "subscribe",
		Params: []byte("{}"),
	}

	cmds = append(cmds, nonConnectFirstCmd)
	cmdBytes, err := json.Marshal(cmds)
	assert.Equal(t, nil, err)
	err = c.message(cmdBytes)
	assert.Equal(t, ErrUnauthorized, err)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:26,代码来源:client_test.go

示例2: TestNamespaceKey

func TestNamespaceKey(t *testing.T) {
	app := testApp()
	assert.Equal(t, NamespaceKey("ns"), app.namespaceKey("ns:channel"))
	assert.Equal(t, NamespaceKey(""), app.namespaceKey("channel"))
	assert.Equal(t, NamespaceKey("ns"), app.namespaceKey("ns:channel:opa"))
	assert.Equal(t, NamespaceKey("ns"), app.namespaceKey("ns::channel"))
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:7,代码来源:application_test.go

示例3: TestToFloat64

func TestToFloat64(t *testing.T) {
	var eight interface{} = 8
	assert.Equal(t, ToFloat64(8), 8.00)
	assert.Equal(t, ToFloat64(8.31), 8.31)
	assert.Equal(t, ToFloat64("8.31"), 8.31)
	assert.Equal(t, ToFloat64(eight), 8.0)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:7,代码来源:cast_test.go

示例4: TestIndirectPointers

func TestIndirectPointers(t *testing.T) {
	x := 13
	y := &x
	z := &y

	assert.Equal(t, ToInt(y), 13)
	assert.Equal(t, ToInt(z), 13)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:8,代码来源:cast_test.go

示例5: TestProjectByKey

func TestProjectByKey(t *testing.T) {
	app := testApp()
	p, found := app.projectByKey("nonexistent")
	assert.Equal(t, found, false)
	p, found = app.projectByKey("test1")
	assert.Equal(t, found, true)
	assert.Equal(t, p.Name, ProjectKey("test1"))
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:8,代码来源:application_test.go

示例6: TestLevels

func TestLevels(t *testing.T) {
	SetStdoutThreshold(LevelError)
	assert.Equal(t, outputThreshold, LevelError)
	SetLogThreshold(LevelCritical)
	assert.Equal(t, logThreshold, LevelCritical)
	assert.NotEqual(t, outputThreshold, LevelCritical)
	SetStdoutThreshold(LevelWarn)
	assert.Equal(t, outputThreshold, LevelWarn)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:9,代码来源:logger_test.go

示例7: TestGetProjectByKey

func TestGetProjectByKey(t *testing.T) {
	s := getTestStructure()

	_, found := s.projectByKey("test3")
	assert.Equal(t, false, found, "found project that does not exist")

	_, found = s.projectByKey("test2")
	assert.Equal(t, true, found)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:9,代码来源:structure_test.go

示例8: TestMemoryPresenceHub

func TestMemoryPresenceHub(t *testing.T) {
	h := newMemoryPresenceHub()
	assert.Equal(t, 0, len(h.presence))

	testCh1 := ChannelID("channel1")
	testCh2 := ChannelID("channel2")

	uid := ConnID("uid")

	info := ClientInfo{
		User:   "user",
		Client: "client",
	}

	h.add(testCh1, uid, info)
	assert.Equal(t, 1, len(h.presence))
	h.add(testCh2, uid, info)
	assert.Equal(t, 2, len(h.presence))
	h.remove(testCh1, uid)
	// remove non existing must not fail
	err := h.remove(testCh1, uid)
	assert.Equal(t, nil, err)
	assert.Equal(t, 1, len(h.presence))
	p, err := h.get(testCh1)
	assert.Equal(t, nil, err)
	assert.Equal(t, 0, len(p))
	p, err = h.get(testCh2)
	assert.Equal(t, nil, err)
	assert.Equal(t, 1, len(p))
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:30,代码来源:enginememory_test.go

示例9: TestStringQueueResize

func TestStringQueueResize(t *testing.T) {
	q := New()
	assert.Equal(t, 0, q.Len())
	assert.Equal(t, initialCapacity, q.Cap())
	assert.Equal(t, false, q.Closed())

	i := 0
	for i < initialCapacity {
		q.Add(strconv.Itoa(i))
		i++
	}
	assert.Equal(t, initialCapacity, q.Cap())
	q.Add("resize here")
	assert.Equal(t, initialCapacity*2, q.Cap())
	q.Remove()
	// back to initial capacity
	assert.Equal(t, initialCapacity, q.Cap())

	q.Add("new resize here")
	assert.Equal(t, initialCapacity*2, q.Cap())
	q.Add("one more item, no resize must happen")
	assert.Equal(t, initialCapacity*2, q.Cap())

	assert.Equal(t, initialCapacity+2, q.Len())
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:25,代码来源:stringqueue_test.go

示例10: TestAPIPresence

func TestAPIPresence(t *testing.T) {
	app := testApp()
	p, _ := app.projectByKey("test1")

	cmd := &presenceApiCommand{
		Channel: "channel",
	}
	resp, err := app.presenceCmd(p, cmd)
	assert.Equal(t, nil, err)
	assert.Equal(t, nil, resp.err)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:11,代码来源:api_test.go

示例11: TestAPIHistory

func TestAPIHistory(t *testing.T) {
	app := testApp()
	p, _ := app.projectByKey("test1")

	cmd := &historyApiCommand{
		Channel: "channel",
	}
	resp, err := app.historyCmd(p, cmd)
	assert.Equal(t, nil, err)
	assert.Equal(t, nil, resp.err)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:11,代码来源:api_test.go

示例12: TestAPIDisconnect

func TestAPIDisconnect(t *testing.T) {
	app := testApp()
	p, _ := app.projectByKey("test1")

	cmd := &disconnectApiCommand{
		User: "test user",
	}
	resp, err := app.disconnectCmd(p, cmd)
	assert.Equal(t, nil, err)
	assert.Equal(t, nil, resp.err)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:11,代码来源:api_test.go

示例13: TestAPIPublish

func TestAPIPublish(t *testing.T) {
	app := testApp()
	p, _ := app.projectByKey("test1")

	cmd := &publishApiCommand{
		Channel: "channel",
		Data:    []byte("null"),
	}
	resp, err := app.publishCmd(p, cmd)
	assert.Equal(t, nil, err)
	assert.Equal(t, nil, resp.err)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:12,代码来源:api_test.go

示例14: TestAdminHub

func TestAdminHub(t *testing.T) {
	h := newAdminHub()
	c := newTestUserCC()
	err := h.add(c)
	assert.Equal(t, err, nil)
	assert.Equal(t, len(h.connections), 1)
	err = h.broadcast("message")
	assert.Equal(t, err, nil)
	err = h.remove(c)
	assert.Equal(t, err, nil)
	assert.Equal(t, len(h.connections), 0)
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:12,代码来源:hubs_test.go

示例15: TestInfoHandler

func TestInfoHandler(t *testing.T) {
	app := testApp()
	r := httptest.NewRecorder()
	req, _ := http.NewRequest("GET", "/info/", nil)
	app.InfoHandler(r, req)
	body, _ := ioutil.ReadAll(r.Body)
	assert.Equal(t, true, strings.Contains(string(body), "nodes"))
	assert.Equal(t, true, strings.Contains(string(body), "node_name"))
	assert.Equal(t, true, strings.Contains(string(body), "version"))
	assert.Equal(t, true, strings.Contains(string(body), "structure"))
	assert.Equal(t, true, strings.Contains(string(body), "engine"))
}
开发者ID:shilkin,项目名称:centrifugo,代码行数:12,代码来源:handlers_test.go


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