本文整理汇总了Golang中github.com/MG-RAST/golib/stretchr/testify/assert.False函数的典型用法代码示例。如果您正苦于以下问题:Golang False函数的具体用法?Golang False怎么用?Golang False使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了False函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSimpleExample
func TestSimpleExample(t *testing.T) {
// build a map from a JSON object
o := MustFromJSON(`{"name":"Mat","foods":["indian","chinese"], "location":{"county":"hobbiton","city":"the shire"}}`)
// Map can be used as a straight map[string]interface{}
assert.Equal(t, o["name"], "Mat")
// Get an Value object
v := o.Get("name")
assert.Equal(t, v, &Value{data: "Mat"})
// Test the contained value
assert.False(t, v.IsInt())
assert.False(t, v.IsBool())
assert.True(t, v.IsStr())
// Get the contained value
assert.Equal(t, v.Str(), "Mat")
// Get a default value if the contained value is not of the expected type or does not exist
assert.Equal(t, 1, v.Int(1))
// Get a value by using array notation
assert.Equal(t, "indian", o.Get("foods[0]").Data())
// Set a value by using array notation
o.Set("foods[0]", "italian")
assert.Equal(t, "italian", o.Get("foods[0]").Str())
// Get a value by using dot notation
assert.Equal(t, "hobbiton", o.Get("location.county").Str())
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:34,代码来源:simple_example_test.go
示例2: TestIssue81
func TestIssue81(t *testing.T) {
p, _ := NewPathPattern("/prefix/static/***")
assert.NotPanics(t, func() {
assert.False(t, p.GetPathMatch(NewPath("/prefix/")).Matches)
})
assert.True(t, p.GetPathMatch(NewPath("/prefix/static")).Matches)
assert.False(t, p.GetPathMatch(NewPath("/static")).Matches)
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:8,代码来源:path_pattern_test.go
示例3: TestPathPattern_GetPathMatchCatchallPrefixLiteral_Matches
func TestPathPattern_GetPathMatchCatchallPrefixLiteral_Matches(t *testing.T) {
// ***/literal
gp, _ := NewPathPattern("/***/books")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/PEOPLE/123/BOOKS")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/People/123/Books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books/")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/books")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("people/123/[books]/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("people/123/{books}/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/books/hello")).Matches)
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:16,代码来源:path_pattern_test.go
示例4: AssertNotCalled
// AssertNotCalled asserts that the method was not called.
func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool {
if !assert.False(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method was called with %d argument(s), but should NOT have been.", methodName, len(arguments))) {
t.Logf("%s", m.ExpectedCalls)
return false
}
return true
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:8,代码来源:mock.go
示例5: TestMapStaticFile
func TestMapStaticFile(t *testing.T) {
codecService := codecsservices.NewWebCodecService()
h := NewHttpHandler(codecService)
h.MapStaticFile("/static-file", "/location/of/static-file")
assert.Equal(t, 1, len(h.HandlersPipe()))
staticHandler := h.HandlersPipe()[0].(*PathMatchHandler)
if assert.Equal(t, 1, len(staticHandler.HttpMethods)) {
assert.Equal(t, goweb_http.MethodGet, staticHandler.HttpMethods[0])
}
var ctx context.Context
var willHandle bool
ctx = context_test.MakeTestContextWithPath("/static-file")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("static-file")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("static-file/")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("static-file/something-else")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.False(t, willHandle, "Static handler NOT should handle")
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:35,代码来源:mapping_test.go
示例6: TestPathMatchHandler_BreakCurrentPipeline
func TestPathMatchHandler_BreakCurrentPipeline(t *testing.T) {
pathPattern, _ := paths.NewPathPattern("collection/{id}/name")
h := NewPathMatchHandler(pathPattern, HandlerExecutionFunc(func(c context.Context) error {
return nil
}))
h.BreakCurrentPipeline = true
ctx1 := context_test.MakeTestContextWithPath("/collection/123/name")
breakCurrentPipeline, _ := h.Handle(ctx1)
assert.True(t, breakCurrentPipeline)
h = NewPathMatchHandler(pathPattern, HandlerExecutionFunc(func(c context.Context) error {
return nil
}))
h.BreakCurrentPipeline = false
ctx1 = context_test.MakeTestContextWithPath("/collection/123/name")
breakCurrentPipeline, _ = h.Handle(ctx1)
assert.False(t, breakCurrentPipeline)
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:26,代码来源:path_match_handler_test.go
示例7: TestPathMatchHandler
func TestPathMatchHandler(t *testing.T) {
pathPattern, _ := paths.NewPathPattern("collection/{id}/name")
var called bool = false
h := NewPathMatchHandler(pathPattern, HandlerExecutionFunc(func(c context.Context) error {
called = true
return nil
}))
ctx1 := context_test.MakeTestContextWithPath("/collection/123/name")
will, _ := h.WillHandle(ctx1)
assert.True(t, will)
h.Handle(ctx1)
assert.True(t, called, "Method should be called")
assert.Equal(t, "123", ctx1.Data().Get(context.DataKeyPathParameters).ObjxMap().Get("id").Data())
ctx2 := context_test.MakeTestContextWithPath("/collection")
will, _ = h.WillHandle(ctx2)
assert.False(t, will)
assert.Nil(t, ctx2.Data().Get(context.DataKeyPathParameters).Data())
h.BreakCurrentPipeline = true
shouldStop, handleErr := h.Handle(ctx2)
assert.Nil(t, handleErr)
assert.True(t, shouldStop)
assert.True(t, called, "Handler func should get called")
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:28,代码来源:path_match_handler_test.go
示例8: TestPathPattern_GetPathMatch_Edges
func TestPathPattern_GetPathMatch_Edges(t *testing.T) {
// everything
gp, _ := NewPathPattern(MatchAllPaths)
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/people")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("")).Matches)
// root
gp, _ = NewPathPattern("/")
assert.True(t, gp.GetPathMatch(NewPath("/")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people")).Matches)
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:17,代码来源:path_pattern_test.go
示例9: TestHas
func TestHas(t *testing.T) {
m := New(TestMap)
assert.True(t, m.Has("name"))
assert.True(t, m.Has("address.state"))
assert.True(t, m.Has("numbers[4]"))
assert.False(t, m.Has("address.state.nope"))
assert.False(t, m.Has("address.nope"))
assert.False(t, m.Has("nope"))
assert.False(t, m.Has("numbers[5]"))
m = nil
assert.False(t, m.Has("nothing"))
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:17,代码来源:tests_test.go
示例10: Test_Arguments_Is
func Test_Arguments_Is(t *testing.T) {
var args Arguments = []interface{}{"string", 123, true}
assert.True(t, args.Is("string", 123, true))
assert.False(t, args.Is("wrong", 456, false))
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:8,代码来源:mock_test.go
示例11: TestPathPattern_GetPathMatch_Matches
func TestPathPattern_GetPathMatch_Matches(t *testing.T) {
// {variable}
gp, _ := NewPathPattern("/people/{id}/books")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/PEOPLE/123/BOOKS")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/People/123/Books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/nope/123/books")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/books/hello")).Matches)
// ***
gp, _ = NewPathPattern("/people/{id}/books/***")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books/hello/how/do/you/do")).Matches, "/people/123/books/hello/how/do/you/do")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books/hello")).Matches, "/people/123/books/hello")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches, "/people/123/books")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books/")).Matches, "/people/123/books/")
// *
gp, _ = NewPathPattern("/people/*/books")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/PEOPLE/123/BOOKS")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/People/123/Books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/nope/123/books")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/books/hello")).Matches)
// [optional]
gp, _ = NewPathPattern("/people/[id]")
assert.True(t, gp.GetPathMatch(NewPath("/people/123")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/people/")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/people")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches)
// /literal/{variable}/*** (should only match IF there's a variable)
gp, _ = NewPathPattern("/people/{id}/***")
assert.True(t, gp.GetPathMatch(NewPath("/people/123")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people")).Matches)
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:50,代码来源:path_pattern_test.go
示例12: TestPathPattern_GetPathMatchCatchallPrefixSuffix_Matches
func TestPathPattern_GetPathMatchCatchallPrefixSuffix_Matches(t *testing.T) {
// ***/literal/***
gp, _ := NewPathPattern("/***/books/***")
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/PEOPLE/123/BOOKS")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/People/123/Books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("people/123/books/")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books/lotr/chapters/one")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/people/123/books/hello")).Matches)
assert.True(t, gp.GetPathMatch(NewPath("/books")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("people/123/[books]/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("people/123/{books}/")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/novels/lotr/chapters/one")).Matches)
assert.False(t, gp.GetPathMatch(NewPath("/people/123/novels/hello")).Matches)
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:19,代码来源:path_pattern_test.go
示例13: Test_Mock_AssertExpectations_With_Repeatability
func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
mockedService.Mock.On("Test_Mock_AssertExpectations_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Twice()
tt := new(testing.T)
assert.False(t, mockedService.AssertExpectations(tt))
// make the call now
mockedService.Mock.Called(1, 2, 3)
assert.False(t, mockedService.AssertExpectations(tt))
mockedService.Mock.Called(1, 2, 3)
// now assert expectations
assert.True(t, mockedService.AssertExpectations(tt))
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:20,代码来源:mock_test.go
示例14: Test_Mock_AssertCalled_WithArguments
func Test_Mock_AssertCalled_WithArguments(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
mockedService.Mock.On("Test_Mock_AssertCalled_WithArguments", 1, 2, 3).Return(5, 6, 7)
mockedService.Mock.Called(1, 2, 3)
tt := new(testing.T)
assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 1, 2, 3))
assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 2, 3, 4))
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:13,代码来源:mock_test.go
示例15: TestMapStatic
func TestMapStatic(t *testing.T) {
codecService := codecsservices.NewWebCodecService()
h := NewHttpHandler(codecService)
h.MapStatic("/static", "/location/of/static")
assert.Equal(t, 1, len(h.HandlersPipe()))
staticHandler := h.HandlersPipe()[0].(*PathMatchHandler)
if assert.Equal(t, 1, len(staticHandler.HttpMethods)) {
assert.Equal(t, goweb_http.MethodGet, staticHandler.HttpMethods[0])
}
var ctx context.Context
var willHandle bool
ctx = context_test.MakeTestContextWithPath("/static/some/deep/file.dat")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("/static/../static/some/deep/file.dat")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("/static/some/../file.dat")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("/static/../file.dat")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.False(t, willHandle, "Static handler should not handle")
ctx = context_test.MakeTestContextWithPath("/static")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("/static/")
willHandle, _ = staticHandler.WillHandle(ctx)
assert.True(t, willHandle, "Static handler should handle")
ctx = context_test.MakeTestContextWithPath("/static/doc.go")
willHandle, _ = staticHandler.WillHandle(ctx)
_, staticHandleErr := staticHandler.Handle(ctx)
if assert.NoError(t, staticHandleErr) {
}
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:51,代码来源:mapping_test.go
示例16: TestExclude
func TestExclude(t *testing.T) {
d := make(Map)
d["name"] = "Mat"
d["age"] = 29
d["secret"] = "ABC"
excluded := d.Exclude([]string{"secret"})
assert.Equal(t, d["name"], excluded["name"])
assert.Equal(t, d["age"], excluded["age"])
assert.False(t, excluded.Has("secret"), "secret should be excluded")
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:14,代码来源:mutations_test.go
示例17: Test_Mock_AssertCalled_WithArguments_With_Repeatability
func Test_Mock_AssertCalled_WithArguments_With_Repeatability(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
mockedService.Mock.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Once()
mockedService.Mock.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4).Return(5, 6, 7).Once()
mockedService.Mock.Called(1, 2, 3)
mockedService.Mock.Called(2, 3, 4)
tt := new(testing.T)
assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3))
assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4))
assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 3, 4, 5))
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:16,代码来源:mock_test.go
示例18: Test_Mock_AssertExpectationsCustomType
func Test_Mock_AssertExpectationsCustomType(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
mockedService.Mock.On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).Return(nil).Once()
tt := new(testing.T)
assert.False(t, mockedService.AssertExpectations(tt))
// make the call now
mockedService.TheExampleMethod3(&ExampleType{})
// now assert expectations
assert.True(t, mockedService.AssertExpectations(tt))
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:16,代码来源:mock_test.go
示例19: Test_AssertExpectationsForObjects_Helper_Failed
func Test_AssertExpectationsForObjects_Helper_Failed(t *testing.T) {
var mockedService1 *TestExampleImplementation = new(TestExampleImplementation)
var mockedService2 *TestExampleImplementation = new(TestExampleImplementation)
var mockedService3 *TestExampleImplementation = new(TestExampleImplementation)
mockedService1.Mock.On("Test_AssertExpectationsForObjects_Helper_Failed", 1).Return()
mockedService2.Mock.On("Test_AssertExpectationsForObjects_Helper_Failed", 2).Return()
mockedService3.Mock.On("Test_AssertExpectationsForObjects_Helper_Failed", 3).Return()
mockedService1.Called(1)
mockedService3.Called(3)
tt := new(testing.T)
assert.False(t, AssertExpectationsForObjects(tt, mockedService1.Mock, mockedService2.Mock, mockedService3.Mock))
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:17,代码来源:mock_test.go
示例20: TestMapAfter_WithMatcherFuncs
func TestMapAfter_WithMatcherFuncs(t *testing.T) {
codecService := codecsservices.NewWebCodecService()
handler := NewHttpHandler(codecService)
matcherFunc := MatcherFunc(func(c context.Context) (MatcherFuncDecision, error) {
return Match, nil
})
handler.MapAfter("/people/{id}", func(c context.Context) error {
return nil
}, matcherFunc)
assert.Equal(t, 1, len(handler.PostHandlersPipe()))
h := handler.PostHandlersPipe()[0].(*PathMatchHandler)
assert.Equal(t, 1, len(h.MatcherFuncs))
assert.Equal(t, matcherFunc, h.MatcherFuncs[0], "Matcher func (first)")
assert.False(t, handler.PostHandlersPipe()[0].(*PathMatchHandler).BreakCurrentPipeline)
}
开发者ID:MG-RAST,项目名称:Shock,代码行数:20,代码来源:mapping_test.go
注:本文中的github.com/MG-RAST/golib/stretchr/testify/assert.False函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论