本文整理汇总了Golang中github.com/golangplus/testing/assert.StringEqual函数的典型用法代码示例。如果您正苦于以下问题:Golang StringEqual函数的具体用法?Golang StringEqual怎么用?Golang StringEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringEqual函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestSortF
func TestSortF(t *testing.T) {
ints := []int{3, 4, 1, 7, 0}
SortF(len(ints), func(i, j int) bool {
return ints[i] < ints[j]
}, func(i, j int) {
ints[i], ints[j] = ints[j], ints[i]
})
assert.StringEqual(t, "ints", ints, []int{0, 1, 3, 4, 7})
ints = []int{3, 4, 1, 7, 0}
SortF(len(ints), func(i, j int) bool {
return ints[i] > ints[j]
}, func(i, j int) {
ints[i], ints[j] = ints[j], ints[i]
})
assert.StringEqual(t, "ints", ints, []int{7, 4, 3, 1, 0})
}
开发者ID:jianjunliu,项目名称:gosl,代码行数:17,代码来源:builtin_test.go
示例17: TestDocInfo
func TestDocInfo(t *testing.T) {
src := DocInfo{
Name: "gcse",
Package: "github.com/daviddengcn/gcse",
Author: "github.com/daviddengcn",
LastUpdated: time.Now(),
StarCount: 10,
Synopsis: "Go Package Search Engine",
Description: "More details about GCSE",
ProjectURL: "http://github.com/daviddengcn/gcse",
ReadmeFn: "readme.txt",
ReadmeData: "Just read me",
Imports: []string{
"github.com/daviddengcn/go-villa",
"github.com/daviddengcn/sophie",
},
TestImports: []string{
"github.com/daviddengcn/go-check",
},
Exported: []string{
"DocInfo", "CheckRuneType",
},
}
var buf bytesp.Slice
assert.NoError(t, src.WriteTo(&buf))
var dst DocInfo
assert.NoError(t, dst.ReadFrom(&buf, -1))
assert.StringEqual(t, "dst", dst, src)
// checking the bug introduced by reusing slice
dst2 := dst
assert.StringEqual(t, "dst2.Imports[0]", dst2.Imports[0],
"github.com/daviddengcn/go-villa")
src.Imports[0] = "github.com/daviddengcn/go-assert"
buf = nil
assert.NoError(t, src.WriteTo(&buf))
assert.NoError(t, dst.ReadFrom(&buf, -1))
assert.StringEqual(t, "dst", dst, src)
assert.StringEqual(t, "dst2.Imports[0]", dst2.Imports[0],
"github.com/daviddengcn/go-villa")
}
开发者ID:digideskio,项目名称:gcse,代码行数:45,代码来源:data_test.go
示例18: TestComplexSliceRemove
func TestComplexSliceRemove(t *testing.T) {
defer __(o_(t))
var s ComplexSlice
s.Add(-1, -2, -3, -4, -5, -6, -7)
assert.Equal(t, "len", len(s), 7)
assert.StringEqual(t, "s", s, "[(-1+0i) (-2+0i) (-3+0i) (-4+0i) (-5+0i) (-6+0i) (-7+0i)]")
s.Fill(2, 5, -9-8i)
assert.StringEqual(t, "s", s, "[(-1+0i) (-2+0i) (-9-8i) (-9-8i) (-9-8i) (-6+0i) (-7+0i)]")
s.RemoveRange(2, 5)
assert.Equal(t, "len", len(s), 4)
assert.StringEqual(t, "s", s, "[(-1+0i) (-2+0i) (-6+0i) (-7+0i)]")
s.Remove(2)
assert.Equal(t, "len", len(s), 3)
assert.StringEqual(t, "s", s, "[(-1+0i) (-2+0i) (-7+0i)]")
}
开发者ID:postfix,项目名称:go-villa,代码行数:19,代码来源:complexslice_test.go
示例19: TestChooseImportantSentenses_GoBot
func TestChooseImportantSentenses_GoBot(t *testing.T) {
TEXT := `
GoBot is an IRC Bot programmed in Golang![Build Status](https://secure.travis-ci.org/prometheus/client_golang.png?branch=master). It is designed to be lightweight and fast.
`
IMPORTANTS := []string{
`GoBot is an IRC Bot programmed in Golang.`,
}
importants := ChooseImportantSentenses(TEXT, "main", "github.com/wei2912/GoBot")
assert.StringEqual(t, "importants", importants, IMPORTANTS)
}
开发者ID:digideskio,项目名称:gcse,代码行数:10,代码来源:text_test.go
示例20: TestChooseImportantSentenses_PackageEscape
func TestChooseImportantSentenses_PackageEscape(t *testing.T) {
TEXT := `
GoBot is an IRC Bot programmed.
`
IMPORTANTS := []string{
`GoBot is an IRC Bot programmed.`,
}
importants := ChooseImportantSentenses(TEXT, "main", "github.com/+wei2912/GoBot")
assert.StringEqual(t, "importants", importants, IMPORTANTS)
}
开发者ID:digideskio,项目名称:gcse,代码行数:10,代码来源:text_test.go
注:本文中的github.com/golangplus/testing/assert.StringEqual函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论