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


Golang assert.Equal函数代码示例

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


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


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