• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestShortRead

func TestShortRead(t *testing.T) {
	var result []byte
	var buf [2]byte

	for _, test := range readerTests {
		result = result[:0]

		var (
			r   = NewReader(Rope{test.r})
			n   int
			err error
		)
		for err == nil {
			n, err = r.Read(buf[:])

			if err == nil {
				assert.NotEqual(t, n, 0, "Zero-length Read()")
			}

			result = append(result, buf[:n]...)
		}
		assert.Equal(t, test.want, string(result))
		assert.Equal(t, err, io.EOF, "Non-EOF error: "+err.Error())
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:25,代码来源:reader_test.go


示例2: TestCrewRenderPlain

func TestCrewRenderPlain(t *testing.T) {
	c := NewCrew("test")

	// Set some variables
	c.Vars = map[string]interface{}{
		"path": "/usr/local/bin",
		"n":    4,
		"x":    3.45,
	}

	// No placeholders
	s, _ := c.Render("python test.py")
	assert.Equal(t, s, "python test.py")

	// Missing key
	s, err := c.Render("{{bindir}}/python test.py")
	assert.NotEqual(t, err, nil)

	// Typical
	s, err = c.Render("{{path}}/python -n {{n}} -x {{x}} test.py")
	assert.Equal(t, s, "/usr/local/bin/python -n 4 -x 3.45 test.py")

	// Single braces aren't affected
	s, err = c.Render("{path}")
	assert.Equal(t, s, "{path}")

	// Escaped braces aren't affected, but replaced
	s, err = c.Render("{\\{path\\}}")
	assert.Equal(t, s, "{{path}}")

	// Escaped braces, round 2
	s, err = c.Render("\\{\\{path\\}\\}")
	assert.Equal(t, s, "{{path}}")
}
开发者ID:bruth,项目名称:playbill,代码行数:34,代码来源:crew_test.go


示例3: TestFullRead

func TestFullRead(t *testing.T) {
	var buf [9]byte // Big enough for all the test strings. Exactly right size for one of them.

	for _, test := range readerTests {
		r := NewReader(Rope{test.r})
		n, err := r.Read(buf[:])

		assert.Equal(t, n, len(test.want), "partial read")
		assert.Equal(t, err, io.EOF, "no immediate EOF")
		assert.Equal(t, test.want, string(buf[:n]), "wrong data")
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:12,代码来源:reader_test.go


示例4: TestFailedRoutineRun

func TestFailedRoutineRun(t *testing.T) {
	r := NewRoutine("git", "flub")
	c := NewCrew("c1")
	rr, err := r.Run(c)

	assert.NotEqual(t, err, nil)
	assert.Equal(t, rr.Done(), true)
	assert.Equal(t, rr.Failed, true)
	assert.Equal(t, rr.Stdin, "")
	assert.Equal(t, rr.Stdout, "")
	assert.Equal(t, rr.Stderr, "git: 'flub' is not a git command. See 'git --help'.\n\nDid you mean this?\n\tpull\n")
}
开发者ID:bruth,项目名称:playbill,代码行数:12,代码来源:routine_test.go


示例5: TestPlayMoveScene

func TestPlayMoveScene(t *testing.T) {
	p := NewPlay("P0", "")
	s0 := NewScene("S0", "")
	s1 := NewScene("S1", "")

	p.AddScene(s0)
	p.AddScene(s1)

	p.MoveScene(0, s1)
	assert.Equal(t, p.Scenes[0], s1)
	assert.Equal(t, p.Scenes[1], s0)
}
开发者ID:bruth,项目名称:playbill,代码行数:12,代码来源:play_test.go


示例6: TestSuccessfulSceneRun

func TestSuccessfulSceneRun(t *testing.T) {
	s := NewScene("S0", "")

	s.NewRoutine("echo", "Hello")
	s.NewRoutine("echo", "Gopher")
	s.NewRoutine("echo", "World")

	c := NewCrew("c1")
	sr, err := s.Run(c)

	assert.Equal(t, err, nil)
	assert.Equal(t, len(sr.Routines), 3)
	assert.Equal(t, sr.Failed, false)
	assert.Equal(t, sr.Done(), true)
}
开发者ID:bruth,项目名称:playbill,代码行数:15,代码来源:scene_test.go


示例7: TestFailedSceneRun

func TestFailedSceneRun(t *testing.T) {
	s := NewScene("S0", "")

	s.NewRoutine("git", "flub")
	s.NewRoutine("echo", "Gopher")
	s.NewRoutine("echo", "World")

	c := NewCrew("c1")
	sr, err := s.Run(c)

	assert.Equal(t, err, nil)
	assert.Equal(t, len(sr.Routines), 3)
	assert.Equal(t, sr.Failed, true)
	assert.Equal(t, sr.Done(), true)
}
开发者ID:bruth,项目名称:playbill,代码行数:15,代码来源:scene_test.go


示例8: TestAt

func TestAt(t *testing.T) {
	str := treeR.String()
	length := treeR.Len()
	for i := int64(0); i < length; i++ {
		assert.Equal(t, str[i], treeR.At(i))
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:7,代码来源:rope_test.go


示例9: TestPlayRun

func TestPlayRun(t *testing.T) {
	p := NewPlay("P0", "")
	c := &Crew{}

	// Nothing to do..
	pr, err := p.Run(c)
	assert.Equal(t, err, nil)
	assert.False(t, pr.Failed)

	// Scene and routine
	s0, _ := p.NewScene("S0", "")
	s0.NewRoutine("echo", "foo")
	pr, err = p.Run(c)
	assert.Equal(t, err, nil)
	assert.False(t, pr.Failed)
}
开发者ID:bruth,项目名称:playbill,代码行数:16,代码来源:play_test.go


示例10: TestTrigger

func TestTrigger(t *testing.T) {
	// Null case
	c, _ := Trigger("testhook", nil)
	assert.Equal(t, c, 0)

	// Local file
	NewLocalHooks()
}
开发者ID:bruth,项目名称:playbill,代码行数:8,代码来源:hooks_test.go


示例11: TestReader

func TestReader(t *testing.T) {
	buf := bytes.NewBuffer(nil)
	for _, test := range readerTests {
		buf.Reset()
		io.Copy(buf, NewReader(Rope{test.r}))
		assert.Equal(t, test.want, buf.String())
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:8,代码来源:reader_test.go


示例12: TestPlayAddScene

func TestPlayAddScene(t *testing.T) {
	p := NewPlay("P0", "")
	s0 := NewScene("S0", "")
	s1 := NewScene("S1", "")

	// Yep..
	p.AddScene(s0)
	assert.Equal(t, p.Scenes[0], s0)

	// Yep..
	p.AddScene(s1)
	assert.Equal(t, p.Scenes[1], s1)

	// Nope..
	err := p.AddScene(s1)
	assert.NotEqual(t, err, nil)
}
开发者ID:bruth,项目名称:playbill,代码行数:17,代码来源:play_test.go


示例13: TestPlayInsertScene

func TestPlayInsertScene(t *testing.T) {
	p := NewPlay("P0", "")
	s0 := NewScene("S0", "")

	// Cannot insert at a position that does not exist
	err := p.InsertScene(0, s0)
	assert.NotEqual(t, err, nil)

	p.AddScene(s0)

	// Insert new scene at position 0
	ns0 := NewScene("New S0", "")
	err = p.InsertScene(0, ns0)
	assert.Equal(t, err, nil)
	assert.Equal(t, p.Scenes[0], ns0)
	assert.Equal(t, p.Scenes[1], s0)
}
开发者ID:bruth,项目名称:playbill,代码行数:17,代码来源:play_test.go


示例14: TestConcatSubstr

func TestConcatSubstr(t *testing.T) {
	defer disableCoalesce()()

	for _, ss := range substrings {
		got := ss.orig.slice(ss.start, ss.end)
		msg := fmt.Sprintf("%q[%v:%v] != %q", Rope{ss.orig}, ss.start, ss.end, Rope{got})
		assert.Equal(t, ss.want, got, msg)
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:9,代码来源:concat_test.go


示例15: TestSlice

func TestSlice(t *testing.T) {
	defer disableCoalesce()()

	// See concat_test.go for the table used.
	for _, ss := range substrings {
		orig := Rope{ss.orig}
		got := orig.Slice(ss.start, ss.end)
		msg := fmt.Sprintf("%q[%v:%v] != %q", orig, ss.start, ss.end, got)
		assert.Equal(t, ss.want, got.node, msg)
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:11,代码来源:rope_test.go


示例16: TestEmptyRope

func TestEmptyRope(t *testing.T) {
	for _, r := range []Rope{Rope{}, New("")} {
		assert.Equal(t, int64(0), r.Len())

		assert.Equal(t, nil, r.Bytes())
		assert.Equal(t, "", r.String())

		assert.Equal(t, "", r.DropPrefix(3).String())
		assert.Equal(t, "", r.DropPrefix(-1).String())
		assert.Equal(t, "", r.DropPostfix(3).String())
		assert.Equal(t, "", r.DropPostfix(-1).String())

		assert.Equal(t, "", r.Slice(-1, 200).String())
		assert.Equal(t, "", r.Slice(0, 1).String())

		buf := bytes.NewBuffer(nil)
		r.WriteTo(buf)
		assert.Equal(t, 0, buf.Len())
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:20,代码来源:rope_test.go


示例17: TestRepeat

func TestRepeat(t *testing.T) {
	r := New("a")
	assert.Equal(t, "", r.Repeat(0).String())
	assert.Equal(t, "a", r.Repeat(1).String())
	assert.Equal(t, "aa", r.Repeat(2).String())
	assert.Equal(t, "aaa", r.Repeat(3).String())
	assert.Equal(t, "aaaa", r.Repeat(4).String())
	assert.Equal(t, "aaaaa", r.Repeat(5).String())
	assert.Equal(t, "aaaaaa", r.Repeat(6).String())
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:10,代码来源:rope_test.go


示例18: TestGoString

func TestGoString(t *testing.T) {
	for i, format := range []string{"%v", "%#v"} {
		for _, str := range []string{"abc", "\""} {
			want := fmt.Sprintf(format, str)
			if MarkGoStringedRope && i == 1 {
				// GoStringer
				want = "/*Rope*/ " + want
			}
			assert.Equal(t, want, fmt.Sprintf(format, New(str)))
		}
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:12,代码来源:rope_test.go


示例19: TestWalk

func TestWalk(t *testing.T) {
	defer disableCoalesce()()

	for _, r := range []Rope{Rope{}, emptyRope} {
		r.Walk(func(_ string) error {
			t.Error("call to empty Rope's Walk parameter")
			return nil
		})
	}

	for _, r := range []Rope{
		New("abc").AppendString("def").AppendString("ghi"),
	} {
		str := r.String()
		err := r.Walk(func(part string) error {
			assert.Equal(t, str[:len(part)], part)
			str = str[len(part):]
			return nil
		})
		assert.Nil(t, err)
		assert.Equal(t, "", str)
	}

	for _, r := range []Rope{
		New("abc").AppendString("def").AppendString("ghi"),
	} {
		str := r.String()
		err := r.Walk(func(part string) error {
			assert.Equal(t, str[:len(part)], part)
			str = str[len(part):]
			if len(str) < 4 {
				return errors.New("stop now")
			}
			return nil
		})
		assert.Equal(t, err, errors.New("stop now"))
		assert.True(t, 0 < len(str) && len(str) < 4)
	}

}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:40,代码来源:rope_test.go


示例20: TestConcatDropPrefix

func TestConcatDropPrefix(t *testing.T) {
	defer disableCoalesce()()

	for _, ss := range substrings {
		if ss.end < ss.orig.length() {
			// Ignore non-suffix substrings
			continue
		}
		got := ss.orig.dropPrefix(ss.start)
		msg := fmt.Sprintf("%q[%v:] != %q", Rope{ss.orig}, ss.start, Rope{got})
		assert.Equal(t, ss.want, got, msg)
	}
}
开发者ID:lunixbochs,项目名称:fvbommel-util,代码行数:13,代码来源:concat_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang doit.DisplayOutput函数代码示例发布时间:2022-05-24
下一篇:
Golang log.Println函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap