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


Golang assert.True函数代码示例

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


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

示例1: TestLinkedSubscriptionUnsubscribesTargetOnLink

func TestLinkedSubscriptionUnsubscribesTargetOnLink(t *testing.T) {
	linked := NewLinkedSubscription()
	sub := NewGenericSubscription()
	linked.Dispose()
	assert.True(t, linked.Disposed())
	assert.False(t, sub.Disposed())
	linked.Link(sub)
	assert.True(t, linked.Disposed())
	assert.True(t, sub.Disposed())
}
开发者ID:alecthomas,项目名称:gorx,代码行数:10,代码来源:gorx_test.go

示例2: TestLinkedSubscription

func TestLinkedSubscription(t *testing.T) {
	linked := NewLinkedSubscription()
	sub := NewGenericSubscription()
	assert.False(t, linked.Disposed())
	assert.False(t, sub.Disposed())
	linked.Link(sub)
	assert.Panics(t, func() { linked.Link(sub) })
	linked.Dispose()
	assert.True(t, sub.Disposed())
	assert.True(t, linked.Disposed())
}
开发者ID:alecthomas,项目名称:gorx,代码行数:11,代码来源:gorx_test.go

示例3: TestCombinedShortFlags

func TestCombinedShortFlags(t *testing.T) {
	app := newTestApp()
	a := app.Flag("short0", "").Short('0').Bool()
	b := app.Flag("short1", "").Short('1').Bool()
	c := app.Flag("short2", "").Short('2').Bool()
	_, err := app.Parse([]string{"-01"})
	assert.NoError(t, err)
	assert.True(t, *a)
	assert.True(t, *b)
	assert.False(t, *c)
}
开发者ID:nextrevision,项目名称:sapt,代码行数:11,代码来源:flags_test.go

示例4: TestChannelSubscription

func TestChannelSubscription(t *testing.T) {
	done := make(chan bool)
	unsubscribed := false
	var s Subscription = NewChannelSubscription()
	events, ok := s.(SubscriptionEvents)
	assert.True(t, ok)
	events.OnUnsubscribe(func() { unsubscribed = true; done <- true })
	assert.False(t, s.Disposed())
	s.Dispose()
	assert.True(t, s.Disposed())
	<-done
	assert.True(t, unsubscribed)
}
开发者ID:alecthomas,项目名称:gorx,代码行数:13,代码来源:gorx_test.go

示例5: TestDoOnComplete

func TestDoOnComplete(t *testing.T) {
	complete := false
	a, err := EmptyInt().DoOnComplete(func() { complete = true }).ToArrayWithError()
	assert.NoError(t, err)
	assert.Equal(t, []int{}, a)
	assert.True(t, complete)
}
开发者ID:alecthomas,项目名称:gorx,代码行数:7,代码来源:gorx_test.go

示例6: TestBool

func TestBool(t *testing.T) {
	app := newTestApp()
	b := app.Flag("b", "").Bool()
	_, err := app.Parse([]string{"--b"})
	assert.NoError(t, err)
	assert.True(t, *b)
}
开发者ID:nextrevision,项目名称:sapt,代码行数:7,代码来源:flags_test.go

示例7: TestShortFlag

func TestShortFlag(t *testing.T) {
	app := newTestApp()
	f := app.Flag("long", "").Short('s').Bool()
	_, err := app.Parse([]string{"-s"})
	assert.NoError(t, err)
	assert.True(t, *f)
}
开发者ID:nextrevision,项目名称:sapt,代码行数:7,代码来源:flags_test.go

示例8: TestNestedCommandWithMergedFlags

func TestNestedCommandWithMergedFlags(t *testing.T) {
	app := New("app", "")
	cmd0 := app.Command("a", "")
	cmd0f0 := cmd0.Flag("aflag", "").Bool()
	// cmd1 := app.Command("b", "")
	// cmd1f0 := cmd0.Flag("bflag", "").Bool()
	cmd00 := cmd0.Command("aa", "")
	cmd00f0 := cmd00.Flag("aaflag", "").Bool()
	err := app.init()
	assert.NoError(t, err)
	context := tokenize(strings.Split("a aa --aflag --aaflag", " "), false)
	selected, err := parseAndExecute(app, context)
	assert.NoError(t, err)
	assert.True(t, *cmd0f0)
	assert.True(t, *cmd00f0)
	assert.Equal(t, "a aa", selected)
}
开发者ID:nextrevision,项目名称:sapt,代码行数:17,代码来源:cmd_test.go

示例9: Test_Renewal

func Test_Renewal(t *testing.T) {
	res := &http.Response{
		StatusCode: 400,
	}
	assert.True(t, needsRenewal(res, nil))

	res.StatusCode = 200
	assert.False(t, needsRenewal(res, nil))
}
开发者ID:itchio,项目名称:go-itchio,代码行数:9,代码来源:itchfs_test.go

示例10: TestTimeout

func TestTimeout(t *testing.T) {
	wg := sync.WaitGroup{}
	start := time.Now()
	wg.Add(1)
	actual, err := CreateInt(func(observer IntObserver, subscription Subscription) {
		observer.Next(1)
		time.Sleep(time.Millisecond * 500)
		assert.True(t, subscription.Disposed())
		wg.Done()
	}).
		Timeout(time.Millisecond * 250).
		ToArrayWithError()
	elapsed := time.Now().Sub(start)
	assert.Error(t, err)
	assert.Equal(t, ErrTimeout, err)
	assert.True(t, elapsed > time.Millisecond*250 && elapsed < time.Millisecond*500)
	assert.Equal(t, []int{1}, actual)
	wg.Wait()
}
开发者ID:alecthomas,项目名称:gorx,代码行数:19,代码来源:gorx_test.go

示例11: TestDispatchCallbackIsCalled

func TestDispatchCallbackIsCalled(t *testing.T) {
	dispatched := false
	c := newTestApp()
	c.Command("cmd", "").Action(func(*ParseContext) error {
		dispatched = true
		return nil
	})

	_, err := c.Parse([]string{"cmd"})
	assert.NoError(t, err)
	assert.True(t, dispatched)
}
开发者ID:bjaglin,项目名称:kingpin,代码行数:12,代码来源:app_test.go

示例12: Test_NewHealer

func Test_NewHealer(t *testing.T) {
	_, err := NewHealer("", "/dev/null")
	assert.Error(t, err)

	_, err = NewHealer("nope,/dev/null", "invalid")
	assert.Error(t, err)

	healer, err := NewHealer("archive,/dev/null", "invalid")
	assert.NoError(t, err)

	_, ok := healer.(*ArchiveHealer)
	assert.True(t, ok)
}
开发者ID:itchio,项目名称:wharf,代码行数:13,代码来源:healer_test.go

示例13: TestNestedCommandsWithArgs

func TestNestedCommandsWithArgs(t *testing.T) {
	app := New("app", "")
	cmd := app.Command("a", "").Command("b", "")
	a := cmd.Arg("a", "").String()
	b := cmd.Arg("b", "").String()
	context := tokenize([]string{"a", "b", "c", "d"}, false)
	selected, err := parseAndExecute(app, context)
	assert.NoError(t, err)
	assert.True(t, context.EOL())
	assert.Equal(t, "a b", selected)
	assert.Equal(t, "c", *a)
	assert.Equal(t, "d", *b)
}
开发者ID:nextrevision,项目名称:sapt,代码行数:13,代码来源:cmd_test.go

示例14: Test_FanOut

func Test_FanOut(t *testing.T) {
	t.Logf("Testing fail fast...")

	ts := &TestSink{
		FailingBlock: BlockLocation{
			FileIndex:  2,
			BlockIndex: 2,
		},
	}
	fos, err := NewFanOutSink(ts, 8)
	assert.NoError(t, err)

	fos.Start()

	hadError := false

	for i := 0; i < 8; i++ {
		for j := 0; j < 8; j++ {
			loc := BlockLocation{
				FileIndex:  int64(i),
				BlockIndex: int64(j),
			}
			sErr := fos.Store(loc, []byte{})
			if sErr != nil {
				hadError = true
			}
		}
	}

	assert.True(t, hadError)

	err = fos.Close()
	assert.NoError(t, err)

	t.Logf("Testing tail errors...")

	fos, err = NewFanOutSink(ts, 8)
	assert.NoError(t, err)

	fos.Start()

	// Store shouldn't err, just queue it...
	err = fos.Store(ts.FailingBlock, []byte{})
	assert.NoError(t, err)

	// but close should catch the error
	err = fos.Close()
	assert.NotNil(t, err)
}
开发者ID:itchio,项目名称:wharf,代码行数:49,代码来源:fanout_test.go

示例15: TestNestedCommandsWithFlags

func TestNestedCommandsWithFlags(t *testing.T) {
	app := New("app", "")
	cmd := app.Command("a", "").Command("b", "")
	a := cmd.Flag("aaa", "").Short('a').String()
	b := cmd.Flag("bbb", "").Short('b').String()
	err := app.init()
	assert.NoError(t, err)
	context := tokenize(strings.Split("a b --aaa x -b x", " "), false)
	selected, err := parseAndExecute(app, context)
	assert.NoError(t, err)
	assert.True(t, context.EOL())
	assert.Equal(t, "a b", selected)
	assert.Equal(t, "x", *a)
	assert.Equal(t, "x", *b)
}
开发者ID:nextrevision,项目名称:sapt,代码行数:15,代码来源:cmd_test.go


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