本文整理匯總了Golang中github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert.Equal函數的典型用法代碼示例。如果您正苦於以下問題:Golang Equal函數的具體用法?Golang Equal怎麽用?Golang Equal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Equal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestMiddlewareGeneralCase
func TestMiddlewareGeneralCase(t *testing.T) {
signature := ""
router := New()
router.Use(func(c *Context) {
signature += "A"
c.Next()
signature += "B"
})
router.Use(func(c *Context) {
signature += "C"
})
router.GET("/", func(c *Context) {
signature += "D"
})
router.NoRoute(func(c *Context) {
signature += " X "
})
router.NoMethod(func(c *Context) {
signature += " XX "
})
// RUN
w := performRequest(router, "GET", "/")
// TEST
assert.Equal(t, w.Code, 200)
assert.Equal(t, signature, "ACDB")
}
示例2: TestChooseData
func TestChooseData(t *testing.T) {
A := "a"
B := "b"
assert.Equal(t, chooseData(A, B), A)
assert.Equal(t, chooseData(nil, B), B)
assert.Panics(t, func() { chooseData(nil, nil) })
}
示例3: TestFilterFlags
func TestFilterFlags(t *testing.T) {
result := filterFlags("text/html ")
assert.Equal(t, result, "text/html")
result = filterFlags("text/html;")
assert.Equal(t, result, "text/html")
}
示例4: TestMiddlewareNoRoute
func TestMiddlewareNoRoute(t *testing.T) {
signature := ""
router := New()
router.Use(func(c *Context) {
signature += "A"
c.Next()
signature += "B"
})
router.Use(func(c *Context) {
signature += "C"
c.Next()
c.Next()
c.Next()
c.Next()
signature += "D"
})
router.NoRoute(func(c *Context) {
signature += "E"
c.Next()
signature += "F"
}, func(c *Context) {
signature += "G"
c.Next()
signature += "H"
})
router.NoMethod(func(c *Context) {
signature += " X "
})
// RUN
w := performRequest(router, "GET", "/")
// TEST
assert.Equal(t, w.Code, 404)
assert.Equal(t, signature, "ACEGHFDB")
}
示例5: TestMiddlewareWrite
func TestMiddlewareWrite(t *testing.T) {
router := New()
router.Use(func(c *Context) {
c.String(400, "hola\n")
})
router.Use(func(c *Context) {
c.XML(400, H{"foo": "bar"})
})
router.Use(func(c *Context) {
c.JSON(400, H{"foo": "bar"})
})
router.GET("/", func(c *Context) {
c.JSON(400, H{"foo": "bar"})
}, func(c *Context) {
c.Render(400, sse.Event{
Event: "test",
Data: "message",
})
})
w := performRequest(router, "GET", "/")
assert.Equal(t, w.Code, 400)
assert.Equal(t, w.Body.String(), `hola
<map><foo>bar</foo></map>{"foo":"bar"}
{"foo":"bar"}
event: test
data: message
`)
}
示例6: TestMiddlewareAbort
func TestMiddlewareAbort(t *testing.T) {
signature := ""
router := New()
router.Use(func(c *Context) {
signature += "A"
})
router.Use(func(c *Context) {
signature += "C"
c.AbortWithStatus(401)
c.Next()
signature += "D"
})
router.GET("/", func(c *Context) {
signature += " X "
c.Next()
signature += " XX "
})
// RUN
w := performRequest(router, "GET", "/")
// TEST
assert.Equal(t, w.Code, 401)
assert.Equal(t, signature, "ACD")
}
示例7: TestBasicAuthSearchCredential
func TestBasicAuthSearchCredential(t *testing.T) {
pairs := processAccounts(Accounts{
"admin": "password",
"foo": "bar",
"bar": "foo",
})
user, found := pairs.searchCredential(authorizationHeader("admin", "password"))
assert.Equal(t, user, "admin")
assert.True(t, found)
user, found = pairs.searchCredential(authorizationHeader("foo", "bar"))
assert.Equal(t, user, "foo")
assert.True(t, found)
user, found = pairs.searchCredential(authorizationHeader("bar", "foo"))
assert.Equal(t, user, "bar")
assert.True(t, found)
user, found = pairs.searchCredential(authorizationHeader("admins", "password"))
assert.Empty(t, user)
assert.False(t, found)
user, found = pairs.searchCredential(authorizationHeader("foo", "bar "))
assert.Empty(t, user)
assert.False(t, found)
user, found = pairs.searchCredential("")
assert.Empty(t, user)
assert.False(t, found)
}
示例8: TestWsFlooding
// Testing to ensure that websocket server does not crash, and that it
// cleans up after itself.
func TestWsFlooding(t *testing.T) {
// New websocket server.
wsServer := NewScumsocketServer(CONNS)
// Keep track of sessions.
sc := &SessionCounter{}
// Register the observer.
oChan := wsServer.SessionManager().SessionOpenEventChannel()
cChan := wsServer.SessionManager().SessionCloseEventChannel()
sc.Run(oChan, cChan)
serveProcess := NewServeScumSocket(wsServer)
errServe := serveProcess.Start()
assert.NoError(t, errServe, "ScumSocketed!")
t.Logf("Flooding...")
// Run. Blocks.
errRun := runWs()
stopC := serveProcess.StopEventChannel()
errStop := serveProcess.Stop(0)
<-stopC
assert.NoError(t, errRun, "ScumSocketed!")
assert.NoError(t, errStop, "ScumSocketed!")
o, c, a := sc.Report()
assert.Equal(t, o, CONNS, "Server registered '%d' opened conns out of '%d'", o, CONNS)
assert.Equal(t, c, CONNS, "Server registered '%d' closed conns out of '%d'", c, CONNS)
assert.Equal(t, a, 0, "Server registered '%d' conns still active after shutting down.", a)
}
示例9: TestParseAccept
func TestParseAccept(t *testing.T) {
parts := parseAccept("text/html , application/xhtml+xml,application/xml;q=0.9, */* ;q=0.8")
assert.Len(t, parts, 4)
assert.Equal(t, parts[0], "text/html")
assert.Equal(t, parts[1], "application/xhtml+xml")
assert.Equal(t, parts[2], "application/xml")
assert.Equal(t, parts[3], "*/*")
}
示例10: assertRangeFilter
func assertRangeFilter(t *testing.T, min, max, res0, res1 string) {
arr, err := _parseSearchQuery("test:" + min + ".." + max)
assert.NoError(t, err)
assert.NotNil(t, arr)
assert.Len(t, arr, 2)
assert.Equal(t, arr[0], &ep.FilterData{"test", ">=", res0})
assert.Equal(t, arr[1], &ep.FilterData{"test", "<=", res1})
}
示例11: TestContextRenderIndentedJSON
// Tests that the response is serialized as JSON
// and Content-Type is set to application/json
func TestContextRenderIndentedJSON(t *testing.T) {
c, w, _ := createTestContext()
c.IndentedJSON(201, H{"foo": "bar", "bar": "foo", "nested": H{"foo": "bar"}})
assert.Equal(t, w.Code, 201)
assert.Equal(t, w.Body.String(), "{\n \"bar\": \"foo\",\n \"foo\": \"bar\",\n \"nested\": {\n \"foo\": \"bar\"\n }\n}")
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/json; charset=utf-8")
}
示例12: TestContextRenderData
// TestContextData tests that the response can be written from `bytesting`
// with specified MIME type
func TestContextRenderData(t *testing.T) {
c, w, _ := createTestContext()
c.Data(201, "text/csv", []byte(`foo,bar`))
assert.Equal(t, w.Code, 201)
assert.Equal(t, w.Body.String(), "foo,bar")
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "text/csv")
}
示例13: TestSuiteGetters
func TestSuiteGetters(t *testing.T) {
suite := new(SuiteTester)
suite.SetT(t)
assert.NotNil(t, suite.Assert())
assert.Equal(t, suite.Assertions, suite.Assert())
assert.NotNil(t, suite.Require())
assert.Equal(t, suite.require, suite.Require())
}
示例14: TestContextNegotiationFormat
func TestContextNegotiationFormat(t *testing.T) {
c, _, _ := createTestContext()
c.Request, _ = http.NewRequest("POST", "", nil)
assert.Panics(t, func() { c.NegotiateFormat() })
assert.Equal(t, c.NegotiateFormat(MIMEJSON, MIMEXML), MIMEJSON)
assert.Equal(t, c.NegotiateFormat(MIMEHTML, MIMEJSON), MIMEHTML)
}
示例15: TestContextRenderString
// TestContextString tests that the response is returned
// with Content-Type set to text/plain
func TestContextRenderString(t *testing.T) {
c, w, _ := createTestContext()
c.String(201, "test %s %d", "string", 2)
assert.Equal(t, w.Code, 201)
assert.Equal(t, w.Body.String(), "test string 2")
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "text/plain; charset=utf-8")
}