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


Golang assert.False函數代碼示例

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


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


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