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


Golang assert.StringEqual函数代码示例

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


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

示例1: TestPath

func TestPath(t *testing.T) {
	p := Path("/")
	assert.StringEqual(t, "p.Join(abc)", p.Join("abc"), filepath.Join(string(p), "abc"))

	p = "abc.efg"
	assert.StringEqual(t, "p.Exe()", p.Ext(), filepath.Ext(string(p)))
}
开发者ID:postfix,项目名称:go-villa,代码行数:7,代码来源:path_test.go

示例2: TestDocDB

func TestDocDB(t *testing.T) {
	var db DocDB = PackedDocDB{NewMemDB("", "")}

	info := DocInfo{
		Name: "github.com/daviddengcn/gcse",
	}
	db.Put("hello", info)
	var info2 DocInfo
	if ok := db.Get("hello", &info2); !ok {
		t.Error("db.Get failed!")
		return
	}
	assert.StringEqual(t, "hello", info2, info)

	if err := db.Iterate(func(key string, val interface{}) error {
		info3, ok := val.(DocInfo)
		if !ok {
			return errors.New("errNotDocInfo")
		}

		assert.StringEqual(t, key, info3, info)
		return nil
	}); err != nil {
		t.Errorf("db.Iterate failed: %v", err)
	}
}
开发者ID:digideskio,项目名称:gcse,代码行数:26,代码来源:crawler_test.go

示例3: TestEditDistanceFFull

func TestEditDistanceFFull(t *testing.T) {
	test := func(a, b string, d int, matA []int, matB []int) {
		ra, rb := []rune(a), []rune(b)
		actD, actMatA, actMatB := EditDistanceFFull(len(ra), len(rb),
			func(iA, iB int) int {
				if ra[iA] == rb[iB] {
					return 0
				}

				return 100
			},
			func(iA int) int {
				return 100 + iA
			},
			func(iB int) int {
				return 110 + iB
			})
		assert.Equal(t, fmt.Sprintf("Edit-distance between %s and %s", a, b), actD, d)
		assert.StringEqual(t, fmt.Sprintf("matA for matchting between %s and %s", a, b), actMatA, matA)
		assert.StringEqual(t, fmt.Sprintf("matB for matchting between %s and %s", a, b), actMatB, matB)
	}

	test("abcd", "bcde", 213, []int{-1, 0, 1, 2}, []int{1, 2, 3, -1})
	test("abcde", "", 510, []int{-1, -1, -1, -1, -1}, []int{})
	test("", "abcde", 560, []int{}, []int{-1, -1, -1, -1, -1})
	test("", "", 0, []int{}, []int{})
	test("abcde", "abcde", 0, []int{0, 1, 2, 3, 4}, []int{0, 1, 2, 3, 4})
	test("abcde", "dabce", 213, []int{1, 2, 3, -1, 4}, []int{-1, 0, 1, 2, 4})
	test("abcde", "abfde", 100, []int{0, 1, 2, 3, 4}, []int{0, 1, 2, 3, 4})
}
开发者ID:daviddengcn,项目名称:go-algs,代码行数:30,代码来源:ed_test.go

示例4: TestMatchTokens1

func TestMatchTokens1(t *testing.T) {
	delT, insT := LineToTokens("{abc{def}ghi}"), LineToTokens("{def}")
	assert.StringEqual(t, "delT", delT, "[{ abc { def } ghi }]")
	assert.StringEqual(t, "insT", insT, "[{ def }]")

	matA, matB := MatchTokens(delT, insT)
	assert.StringEqual(t, "matA", matA, "[-1 -1 0 1 2 -1 -1]")
	assert.StringEqual(t, "matB", matB, "[2 3 4]")
}
开发者ID:postfix,项目名称:go-diff,代码行数:9,代码来源:tm_test.go

示例5: TestStrDiff

func TestStrDiff(t *testing.T) {
	defer __(o_(t))

	s1 := StringSlice{"a", "b", "d", "f"}
	s2 := StringSlice{"b", "c", "d", "g"}

	d1, d2 := StrValueCompare.DiffSlicePair(s1, s2)
	assert.StringEqual(t, "d1", d1, "[a f]")
	assert.StringEqual(t, "d2", d2, "[c g]")
}
开发者ID:postfix,项目名称:go-villa,代码行数:10,代码来源:cmp_test.go

示例6: TestNodeToLines_Literal

func TestNodeToLines_Literal(t *testing.T) {
	info, err := parse("", `
package main

func main() {
	a := Da {
		A: 10,
		B: 20,
	}
}

	`)
	if !assert.NoError(t, err) {
		return
	}

	lines := info.funcs.sourceLines("")
	assert.StringEqual(t, "lines", lines, strings.Split(
		`func main() {
    a := Da{
        A: 10,
        B: 20,
    }
}`, "\n"))
}
开发者ID:daviddengcn,项目名称:go-diff,代码行数:25,代码来源:godiff_test.go

示例7: TestStrSet_nil

func TestStrSet_nil(t *testing.T) {
	var s, ss StrSet
	assert.Equal(t, "nil.In(david)", s.In("david"), false)
	assert.Equal(t, "nil.Equals(nil)", s.Equals(ss), true)
	assert.StringEqual(t, "nil.Elements()", s.Elements(), StringSlice{})
	s.Delete("david")
}
开发者ID:postfix,项目名称:go-villa,代码行数:7,代码来源:strset_test.go

示例8: TestSplitSentences

func TestSplitSentences(t *testing.T) {
	TEXT := `
Package gcse is the core supporting library for go-code-search-engine (GCSE).
Its exported types and functions are mainly for sub packages. If you want
some of the function, copy the code away.

Sub-projects

 crawler  crawling packages

indexer  creating index data for web-server 

 --== Godit - a very religious text editor ==--

server   providing web services, including home/top/search services.
`
	SENTS := []string{
		`Package gcse is the core supporting library for go-code-search-engine (GCSE).`,
		`Its exported types and functions are mainly for sub packages.`,
		`If you want some of the function, copy the code away.`,
		`Sub-projects`,
		`crawler crawling packages`,
		`indexer creating index data for web-server`,
		`Godit - a very religious text editor`,
		`server providing web services, including home/top/search services.`,
	}
	sents := SplitSentences(TEXT)
	assert.StringEqual(t, "Sentences", sents, SENTS)
}
开发者ID:digideskio,项目名称:gcse,代码行数:29,代码来源:text_test.go

示例9: TestSliceRemove

func TestSliceRemove(t *testing.T) {
	defer __(o_(t))

	var s Slice
	s.Add(1, 2, 3, 4, 5, 6, 7)
	assert.Equal(t, "len(s)", len(s), 7)
	assert.StringEqual(t, "s", s, "[1 2 3 4 5 6 7]")

	s.RemoveRange(2, 5)
	assert.Equal(t, "len(s)", len(s), 4)
	assert.StringEqual(t, "s", s, "[1 2 6 7]")

	s.Remove(2)
	assert.Equal(t, "len(s)", len(s), 3)
	assert.StringEqual(t, "s", s, "[1 2 7]")
}
开发者ID:postfix,项目名称:go-villa,代码行数:16,代码来源:slice_test.go

示例10: TestDocDB_Export

func TestDocDB_Export(t *testing.T) {
	var db DocDB = PackedDocDB{NewMemDB("", "")}

	info := DocInfo{
		Name: "github.com/daviddengcn/gcse",
	}

	db.Put("go", info)

	if err := db.Export(villa.Path("."), "testexport_db"); err != nil {
		t.Errorf("db.Export failed: %v", err)
		return
	}

	var newDB DocDB = PackedDocDB{NewMemDB(villa.Path("."), "testexport_db")}
	count := 0
	if err := newDB.Iterate(func(key string, val interface{}) error {
		info, ok := val.(DocInfo)
		if !ok {
			return errors.New("Not a DocInfo object")
		}
		assert.StringEqual(t, "info.Name", info.Name,
			"github.com/daviddengcn/gcse")
		count++
		return nil
	}); err != nil {
		t.Errorf("newDB.Iterate failed: %v", err)
	}

	assert.Equal(t, "count", count, 1)
}
开发者ID:digideskio,项目名称:gcse,代码行数:31,代码来源:crawler_test.go

示例11: TestDiffLines_2

func TestDiffLines_2(t *testing.T) {
	var buf bytesp.Slice
	gOut = &buf

	src := strings.Split(`abc
{
  hello
}
defg`, "\n")
	dst := strings.Split(`abc
{
  gogogo
}
{
  hello
}
defg`, "\n")
	diffLines(src, dst, "%s")

	t.Logf("Diff: %s", string(buf))

	assert.StringEqual(t, "diff", strings.Split(string(buf), "\n"),
		strings.Split(`    abc
+++ {
+++   gogogo
+++ }
    {
        ... (2 lines)
    defg
`, "\n"))
}
开发者ID:daviddengcn,项目名称:go-diff,代码行数:31,代码来源:godiff_test.go

示例12: TestIntMatrix

func TestIntMatrix(t *testing.T) {
	defer __(o_(t))

	mat := NewIntMatrix(5, 4)
	assert.Equal(t, "mat.Rows()", mat.Rows(), 5)
	assert.Equal(t, "mat.Cols()", mat.Cols(), 4)
	assert.StringEqual(t, "mat", mat, "[[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]")

	mat.Fill(10)
	assert.StringEqual(t, "mat", mat, "[[10 10 10 10] [10 10 10 10] [10 10 10 10] [10 10 10 10] [10 10 10 10]]")

	mat[1][1] = 0
	mat[3][2] = 12345
	mat[2][0] = -998
	t.Logf("%s", mat.PrettyString())
}
开发者ID:daviddengcn,项目名称:go-villa,代码行数:16,代码来源:intmat_test.go

示例13: TestEditDistanceFull

func TestEditDistanceFull(t *testing.T) {
	test := func(a, b string, d int, matA, matB []int) {
		actD, actMatA, actMatB := EditDistanceFull(&stringInterface{[]rune(a), []rune(b)})
		assert.Equal(t, fmt.Sprintf("Edit-distance between %s and %s", a, b), actD, d)
		assert.StringEqual(t, fmt.Sprintf("matA for matchting between %s and %s", a, b), actMatA, matA)
		assert.StringEqual(t, fmt.Sprintf("matB for matchting between %s and %s", a, b), actMatB, matB)
	}

	test("abcd", "bcde", 213, []int{-1, 0, 1, 2}, []int{1, 2, 3, -1})
	test("abcde", "", 510, []int{-1, -1, -1, -1, -1}, []int{})
	test("", "abcde", 560, []int{}, []int{-1, -1, -1, -1, -1})
	test("", "", 0, []int{}, []int{})
	test("abcde", "abcde", 0, []int{0, 1, 2, 3, 4}, []int{0, 1, 2, 3, 4})
	test("abcde", "dabce", 213, []int{1, 2, 3, -1, 4}, []int{-1, 0, 1, 2, 4})
	test("abcde", "abfde", 100, []int{0, 1, 2, 3, 4}, []int{0, 1, 2, 3, 4})
}
开发者ID:daviddengcn,项目名称:go-algs,代码行数:16,代码来源:ed_test.go

示例14: TestStringSliceRemove

func TestStringSliceRemove(t *testing.T) {
	defer __(o_(t))

	var s StringSlice
	s.Add("A", "B", "C", "D", "E", "F", "G")
	assert.Equal(t, "len(s)", len(s), 7)
	assert.StringEqual(t, "s", s, "[A B C D E F G]")

	s.RemoveRange(2, 5)
	assert.Equal(t, "len(s)", len(s), 4)
	assert.StringEqual(t, "s", s, "[A B F G]")

	s.Remove(2)
	assert.Equal(t, "len(s)", len(s), 3)
	assert.StringEqual(t, "s", s, "[A B G]")
}
开发者ID:postfix,项目名称:go-villa,代码行数:16,代码来源:strslice_test.go

示例15: TestIntMatrix_Clone

func TestIntMatrix_Clone(t *testing.T) {
	// Clone for null matrix, assure no panic
	mat := IntMatrix(nil)
	mat.Clone()
	mat.Fill(0)
	assert.Equal(t, "mat.Rows()", mat.Rows(), 0)
	assert.Equal(t, "mat.Cols()", mat.Cols(), 0)

	// Clone for non-null matrix
	mat = NewIntMatrix(2, 2)
	mat.Fill(1)
	matB := mat.Clone()
	// Change contents of mat, matB should not be changed.
	mat.Fill(2)
	assert.StringEqual(t, "mat", mat, "[[2 2] [2 2]]")
	assert.StringEqual(t, "matB", matB, "[[1 1] [1 1]]")
}
开发者ID:daviddengcn,项目名称:go-villa,代码行数:17,代码来源:intmat_test.go


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