本文整理汇总了Golang中github.com/alecthomas/assert.True函数的典型用法代码示例。如果您正苦于以下问题:Golang True函数的具体用法?Golang True怎么用?Golang True使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了True函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestRetry
func TestRetry(t *testing.T) {
errored := false
a := CreateInt(func(observer IntObserver, subscription Subscription) {
observer.Next(1)
observer.Next(2)
observer.Next(3)
if errored {
observer.Complete()
} else {
observer.Error(errors.New("error"))
errored = true
}
})
b := a.Retry().ToArray()
assert.Equal(t, []int{1, 2, 3, 1, 2, 3}, b)
assert.True(t, errored)
}
开发者ID:alecthomas,项目名称:gorx,代码行数:17,代码来源:gorx_test.go
示例17: TestArgMultipleRequired
func TestArgMultipleRequired(t *testing.T) {
terminated := false
app := New("test", "")
app.Version("0.0.0").Writer(ioutil.Discard)
app.Arg("a", "").Required().String()
app.Arg("b", "").Required().String()
app.Terminate(func(int) { terminated = true })
_, err := app.Parse([]string{})
assert.Error(t, err)
_, err = app.Parse([]string{"A"})
assert.Error(t, err)
_, err = app.Parse([]string{"A", "B"})
assert.NoError(t, err)
_, err = app.Parse([]string{"--version"})
assert.True(t, terminated)
}
开发者ID:ferfebles,项目名称:pome,代码行数:17,代码来源:args_test.go
示例18: TestNestedCommands
func TestNestedCommands(t *testing.T) {
app := New("app", "")
sub1 := app.Command("sub1", "")
sub1.Flag("sub1", "")
subsub1 := sub1.Command("sub1sub1", "")
subsub1.Command("sub1sub1end", "")
sub2 := app.Command("sub2", "")
sub2.Flag("sub2", "")
sub2.Command("sub2sub1", "")
context := tokenize([]string{"sub1", "sub1sub1", "sub1sub1end"}, false)
selected, err := parseAndExecute(app, context)
assert.NoError(t, err)
assert.True(t, context.EOL())
assert.Equal(t, "sub1 sub1sub1 sub1sub1end", selected)
}
开发者ID:nextrevision,项目名称:sapt,代码行数:17,代码来源:cmd_test.go
示例19: TestFork
func TestFork(t *testing.T) {
ch := make(chan int, 30)
s := FromIntChannel(ch).Fork()
a := []int{}
b := []int{}
sub := s.SubscribeNext(func(n int) { a = append(a, n) })
s.SubscribeNext(func(n int) { b = append(b, n) })
ch <- 1
ch <- 2
ch <- 3
runtime.Gosched()
sub.Dispose()
assert.True(t, sub.Disposed())
ch <- 4
close(ch)
s.Wait()
assert.Equal(t, []int{1, 2, 3, 4}, b)
assert.Equal(t, []int{1, 2, 3}, a)
}
开发者ID:alecthomas,项目名称:gorx,代码行数:19,代码来源:gorx_test.go
示例20: runPatchingScenario
//.........这里部分代码省略.........
InPlace: true,
Consumer: consumer,
}
if setup != nil {
setup(actx)
}
patchReader := bytes.NewReader(patchBuffer.Bytes())
aErr := actx.ApplyPatch(patchReader)
if aErr != nil {
return aErr
}
if actx.Signature == nil {
vErr := AssertValid(v1Before, signature)
if vErr != nil {
return vErr
}
}
return nil
}
func() {
log("In-place with failing vet")
var NotVettingError = errors.New("not vetting this")
pErr := runExtraTest(func(actx *ApplyContext) {
actx.VetApply = func(actx *ApplyContext) error {
return NotVettingError
}
})
assert.Error(t, pErr)
assert.True(t, errors.Is(pErr, NotVettingError))
}()
func() {
log("In-place with signature (failfast, passing)")
assert.NoError(t, runExtraTest(func(actx *ApplyContext) {
actx.Signature = signature
}))
}()
func() {
log("In-place with signature (failfast, failing)")
assert.Error(t, runExtraTest(func(actx *ApplyContext) {
actx.Signature = signature
makeTestDir(t, v1Before, *scenario.corruptions)
}))
}()
func() {
log("In-place with signature (wounds, passing)")
assert.NoError(t, runExtraTest(func(actx *ApplyContext) {
actx.Signature = signature
actx.WoundsPath = woundsPath
}))
_, sErr := os.Lstat(woundsPath)
assert.Error(t, sErr)
assert.True(t, os.IsNotExist(sErr))
}()
func() {
log("In-place with signature (wounds, failing)")
assert.NoError(t, runExtraTest(func(actx *ApplyContext) {
开发者ID:itchio,项目名称:wharf,代码行数:67,代码来源:patching_test.go
注:本文中的github.com/alecthomas/assert.True函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论