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


Golang assert.Equal函数代码示例

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


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

示例1: TestSanitizePath

func TestSanitizePath(t *testing.T) {
	assert.Equal(t, "", sanitizePath("////"))
	assert.Equal(t, "", sanitizePath("/../.."))
	assert.Equal(t, "a", sanitizePath("/a//b/.."))
	assert.Equal(t, "a", sanitizePath("../a"))
	assert.Equal(t, "a", sanitizePath("./a"))
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:7,代码来源:cache_test.go

示例2: TestAccumulatorStrings

func TestAccumulatorStrings(t *testing.T) {
	target := []string{}
	acc := newAccumulator(&target, func(v interface{}) Value { return newStringValue(v.(*string)) })
	acc.Set("a")
	assert.Equal(t, []string{"a"}, target)
	acc.Set("b")
	assert.Equal(t, []string{"a", "b"}, target)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:8,代码来源:values_test.go

示例3: TestInterspersedFalse

func TestInterspersedFalse(t *testing.T) {
	app := New("test", "help").Interspersed(false)
	a1 := app.Arg("a1", "").String()
	a2 := app.Arg("a2", "").String()
	f1 := app.Flag("flag", "").String()

	_, err := app.Parse([]string{"a1", "--flag=flag"})
	assert.NoError(t, err)
	assert.Equal(t, "a1", *a1)
	assert.Equal(t, "--flag=flag", *a2)
	assert.Equal(t, "", *f1)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:12,代码来源:app_test.go

示例4: 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"})
	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:musha68k,项目名称:go-ipfs,代码行数:13,代码来源:cmd_test.go

示例5: TestDefaultSubcommandWithFlags

func TestDefaultSubcommandWithFlags(t *testing.T) {
	app := New("app", "").Terminate(nil)
	c0 := app.Command("c0", "").Default()
	_ = c0.Flag("f0", "").Int()
	c0c1 := c0.Command("c1", "").Default()
	c0c1f1 := c0c1.Flag("f1", "").Int()
	selected, err := app.Parse([]string{"--f1=2"})
	assert.NoError(t, err)
	assert.Equal(t, "c0 c1", selected)
	assert.Equal(t, 2, *c0c1f1)
	_, err = app.Parse([]string{"--f2"})
	assert.Error(t, err)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:13,代码来源:cmd_test.go

示例6: TestDefaultSubcommandWithArg

func TestDefaultSubcommandWithArg(t *testing.T) {
	app := New("app", "").Terminate(nil)
	c0 := app.Command("c0", "").Default()
	c01 := c0.Command("c01", "").Default()
	c012 := c01.Command("c012", "").Default()
	a0 := c012.Arg("a0", "").String()
	c0.Command("c02", "")

	cmd, err := app.Parse([]string{"c0", "hello"})
	assert.NoError(t, err)
	assert.Equal(t, "c0 c01 c012", cmd)
	assert.Equal(t, "hello", *a0)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:13,代码来源:cmd_test.go

示例7: TestParseBase2Bytes

func TestParseBase2Bytes(t *testing.T) {
	n, err := ParseBase2Bytes("0B")
	assert.NoError(t, err)
	assert.Equal(t, 0, n)
	n, err = ParseBase2Bytes("1KB")
	assert.NoError(t, err)
	assert.Equal(t, 1024, n)
	n, err = ParseBase2Bytes("1MB1KB25B")
	assert.NoError(t, err)
	assert.Equal(t, 1049625, n)
	n, err = ParseBase2Bytes("1.5MB")
	assert.NoError(t, err)
	assert.Equal(t, 1572864, n)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:14,代码来源:bytes_test.go

示例8: TestParseMetricBytes

func TestParseMetricBytes(t *testing.T) {
	n, err := ParseMetricBytes("0B")
	assert.NoError(t, err)
	assert.Equal(t, 0, n)
	n, err = ParseMetricBytes("1KB1B")
	assert.NoError(t, err)
	assert.Equal(t, 1001, n)
	n, err = ParseMetricBytes("1MB1KB25B")
	assert.NoError(t, err)
	assert.Equal(t, 1001025, n)
	n, err = ParseMetricBytes("1.5MB")
	assert.NoError(t, err)
	assert.Equal(t, 1500000, n)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:14,代码来源:bytes_test.go

示例9: 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", " "))
	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:musha68k,项目名称:go-ipfs,代码行数:15,代码来源:cmd_test.go

示例10: TestParseContextPush

func TestParseContextPush(t *testing.T) {
	app := New("test", "")
	app.Command("foo", "").Command("bar", "")
	c := tokenize([]string{"foo", "bar"})
	a := c.Next()
	assert.Equal(t, TokenArg, a.Type)
	b := c.Next()
	assert.Equal(t, TokenArg, b.Type)
	c.Push(b)
	c.Push(a)
	a = c.Next()
	assert.Equal(t, "foo", a.Value)
	b = c.Next()
	assert.Equal(t, "bar", b.Value)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:15,代码来源:parser_test.go

示例11: TestCommander

func TestCommander(t *testing.T) {
	c := New("test", "test")
	ping := c.Command("ping", "Ping an IP address.")
	pingTTL := ping.Flag("ttl", "TTL for ICMP packets").Short('t').Default("5s").Duration()

	selected, err := c.Parse([]string{"ping"})
	assert.NoError(t, err)
	assert.Equal(t, "ping", selected)
	assert.Equal(t, 5*time.Second, *pingTTL)

	selected, err = c.Parse([]string{"ping", "--ttl=10s"})
	assert.NoError(t, err)
	assert.Equal(t, "ping", selected)
	assert.Equal(t, 10*time.Second, *pingTTL)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:15,代码来源:app_test.go

示例12: TestParserExpandFromFile

func TestParserExpandFromFile(t *testing.T) {
	f, err := ioutil.TempFile("", "")
	assert.NoError(t, err)
	defer os.Remove(f.Name())
	f.WriteString("hello\nworld\n")
	f.Close()

	app := New("test", "")
	arg0 := app.Arg("arg0", "").String()
	arg1 := app.Arg("arg1", "").String()

	_, err = app.Parse([]string{"@" + f.Name()})
	assert.NoError(t, err)
	assert.Equal(t, "hello", *arg0)
	assert.Equal(t, "world", *arg1)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:16,代码来源:parser_test.go

示例13: TestTopLevelArgWorks

func TestTopLevelArgWorks(t *testing.T) {
	c := New("test", "test")
	s := c.Arg("arg", "help").String()
	_, err := c.Parse([]string{"foo"})
	assert.NoError(t, err)
	assert.Equal(t, "foo", *s)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:7,代码来源:app_test.go

示例14: TestCombinedShortFlagArg

func TestCombinedShortFlagArg(t *testing.T) {
	a := New("test", "")
	n := a.Flag("short", "").Short('s').Int()
	_, err := a.Parse([]string{"-s10"})
	assert.NoError(t, err)
	assert.Equal(t, 10, *n)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:7,代码来源:flags_test.go

示例15: TestParseIP

func TestParseIP(t *testing.T) {
	p := parserMixin{}
	v := p.IP()
	p.value.Set("10.1.1.2")
	ip := net.ParseIP("10.1.1.2")
	assert.Equal(t, ip, *v)
}
开发者ID:musha68k,项目名称:go-ipfs,代码行数:7,代码来源:parsers_test.go


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