本文整理汇总了Golang中github.com/bmizerany/assert.Equalf函数的典型用法代码示例。如果您正苦于以下问题:Golang Equalf函数的具体用法?Golang Equalf怎么用?Golang Equalf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equalf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestMarshalRoundTrip
func TestMarshalRoundTrip(t *testing.T) {
const p, pPrime = 14, 25
testCases := []struct {
p, pPrime uint
}{
{5, 10},
{10, 25},
{15, 25},
}
for _, testCase := range testCases {
h := NewHll(testCase.p, testCase.pPrime)
for i := uint64(0); i <= 1e5; i++ {
if i%5000 == 0 {
// Every N elements, do a round-trip marshal and unmarshal and make sure cardinality is
// preserved.
jBuf, err := json.Marshal(h)
assert.Equalf(t, nil, err, "%v", err)
rt := &Hll{}
err = json.Unmarshal(jBuf, rt)
assert.Equalf(t, nil, err, "%v", err)
assert.Equal(t, rt.Cardinality(), h.Cardinality())
}
h.Add(randUint64(t))
}
assert.T(t, !h.isSparse) // Ensure we stored enough to use the dense representation.
}
}
开发者ID:postfix,项目名称:hll,代码行数:33,代码来源:marshal_test.go
示例2: TestCsvModuleArguments
func TestCsvModuleArguments(t *testing.T) {
skipIfCgoCheckActive(t)
db := open(t)
defer checkClose(db, t)
err := LoadCsvModule(db)
checkNoError(t, err, "couldn't create CSV module: %s")
for _, tt := range csvModuleTests {
ddl := []byte("CREATE VIRTUAL TABLE vtab USING csv(")
for i, arg := range tt.Args {
if i > 0 {
ddl = append(ddl, ", "...)
}
ddl = append(ddl, arg...)
}
ddl = append(ddl, ")"...)
//println("DDL: ", string(ddl))
err = db.Exec(string(ddl))
if tt.Error != "" {
if err == nil || !strings.Contains(err.Error(), tt.Error) {
t.Errorf("%s: error %v, want error %q", tt.Name, err, tt.Error)
}
continue
} else {
checkNoError(t, err, "couldn't create CSV virtual table: %s")
}
if tt.Count > 0 {
var count int
err = db.OneValue("SELECT count(1) FROM vtab", &count)
checkNoError(t, err, "couldn't select from CSV virtual table: %s")
assert.Equalf(t, tt.Count, count, "%s: got %d rows, want %d", tt.Name, count, tt.Count)
}
/*var schema string
err = db.OneValue("SELECT sql FROM sqlite_master WHERE name like ? and type = ?", &schema, "vtab", "table")
checkNoError(t, err, "couldn't get schema of CSV virtual table: %s")
println("SCHEMA:", schema)*/
if len(tt.Names) > 0 {
cols, err := db.Columns("", "vtab")
checkNoError(t, err, "couldn't get columns of CSV virtual table: %s")
assert.Equalf(t, len(tt.Names), len(cols), "%s: got %d columns, want %d", tt.Name, len(cols), len(tt.Names))
for i, col := range cols {
assert.Equalf(t, tt.Names[i], col.Name, "%s: got %s, want %s as column name at %d", tt.Name, col.Name, tt.Names[i], i+1)
}
}
if len(tt.Types) > 0 {
cols, err := db.Columns("", "vtab")
checkNoError(t, err, "couldn't get columns of CSV virtual table: %s")
assert.Equalf(t, len(tt.Types), len(cols), "%s: got %d columns, want %d", tt.Name, len(cols), len(tt.Types))
for i, col := range cols {
assert.Equalf(t, tt.Types[i], col.DataType, "%s: got %s, want %s as column type at %d", tt.Name, col.DataType, tt.Types[i], i+1)
}
}
err = db.Exec("DROP TABLE vtab")
checkNoError(t, err, "couldn't drop CSV virtual table: %s")
}
}
开发者ID:gwenn,项目名称:gosqlite,代码行数:60,代码来源:csv_test.go
示例3: TestQuit
// Test the quit command works...
func TestQuit(t *testing.T) {
testInit(t)
const (
Key1 = "fooz"
Val1 = "barz"
)
_, err := cn.Set(Key1, Val1, 0, 0, 0)
assert.Equalf(t, mcNil, err, "unexpected error: %v", err)
v, _, _, err := cn.Get(Key1)
assert.Equalf(t, mcNil, err, "unexpected error: %v", err)
assert.Equalf(t, Val1, v, "wrong value: %s", v)
err = cn.Quit()
assert.Equalf(t, mcNil, err, "unexpected error: %v", err)
_, _, _, err = cn.Get(Key1)
assert.NotEqual(t, mcNil, err, "expected an error (closed connection)")
err = cn.Quit()
assert.NotEqual(t, mcNil, err, "expected an error (closed connection)")
cn = nil
}
开发者ID:memcachier,项目名称:mc,代码行数:27,代码来源:mc_test.go
示例4: DoTestPatchFileAppend
func DoTestPatchFileAppend(t *testing.T, mkrepo repoMaker) {
tg := treegen.New()
treeSpec := tg.D("foo", tg.F("bar", tg.B(42, 65537), tg.B(43, 65537)))
srcpath := treegen.TestTree(t, treeSpec)
defer os.RemoveAll(srcpath)
srcRepo := mkrepo(t)
defer srcRepo.Close()
srcStore, err := fs.NewLocalStore(srcpath, srcRepo)
assert.T(t, err == nil)
tg = treegen.New()
treeSpec = tg.D("foo", tg.F("bar", tg.B(42, 65537)))
dstpath := treegen.TestTree(t, treeSpec)
defer os.RemoveAll(dstpath)
dstRepo := mkrepo(t)
defer dstRepo.Close()
dstStore, err := fs.NewLocalStore(dstpath, dstRepo)
assert.T(t, err == nil)
patchPlan := NewPatchPlan(srcStore, dstStore)
// printPlan(patchPlan)
complete := false
for i, cmd := range patchPlan.Cmds {
switch {
case i == 0:
localTemp, isTemp := cmd.(*LocalTemp)
assert.T(t, isTemp)
assert.Equal(t, filepath.Join(dstpath, "foo", "bar"), localTemp.Path.Resolve())
case i >= 1 && i <= 8:
ltc, isLtc := cmd.(*LocalTempCopy)
assert.Tf(t, isLtc, "cmd %d", i)
assert.Equal(t, ltc.LocalOffset, ltc.TempOffset)
assert.Equal(t, int64(fs.BLOCKSIZE), ltc.Length)
assert.Equal(t, int64(0), ltc.LocalOffset%int64(fs.BLOCKSIZE))
case i == 9:
stc, isStc := cmd.(*SrcTempCopy)
assert.T(t, isStc)
assert.Equal(t, int64(65538), stc.Length)
case i == 10:
_, isRwt := cmd.(*ReplaceWithTemp)
assert.T(t, isRwt)
complete = true
case i > 10:
t.Fatalf("too many commands")
}
}
assert.T(t, complete, "missing expected number of commands")
failedCmd, err := patchPlan.Exec()
assert.Tf(t, failedCmd == nil && err == nil, "%v: %v", failedCmd, err)
srcRoot, errors := fs.IndexDir(srcpath, fs.NewMemRepo())
assert.Equalf(t, 0, len(errors), "%v", errors)
dstRoot, errors := fs.IndexDir(dstpath, fs.NewMemRepo())
assert.Equalf(t, 0, len(errors), "%v", errors)
assert.Equal(t, srcRoot.Info().Strong, dstRoot.Info().Strong)
}
开发者ID:cmars,项目名称:replican-sync,代码行数:60,代码来源:patch_test.go
示例5: TestGetTypedRelationships
// 18.5.12. Get typed relationships
func TestGetTypedRelationships(t *testing.T) {
db := connectTest(t)
defer cleanup(t, db)
// Create
relType0 := rndStr(t)
relType1 := rndStr(t)
n0, _ := db.CreateNode(Props{})
n1, _ := db.CreateNode(Props{})
r0, _ := n0.Relate(relType0, n1.Id(), Props{})
r1, _ := n0.Relate(relType1, n1.Id(), Props{})
// Check one type of relationship
rels, err := n0.Relationships(relType0)
if err != nil {
t.Error(err)
}
assert.Equalf(t, len(rels), 1, "Wrong number of relationships")
_, present := rels.Map()[r0.Id()]
assert.Tf(t, present, "Missing expected relationship")
// Check two types of relationship together
rels, err = n0.Relationships(relType0, relType1)
if err != nil {
t.Error(err)
}
assert.Equalf(t, len(rels), 2, "Wrong number of relationships")
for _, r := range []*Relationship{r0, r1} {
_, present := rels.Map()[r.Id()]
assert.Tf(t, present, "Missing expected relationship")
}
}
开发者ID:jmcvetta,项目名称:neo4j,代码行数:30,代码来源:relationship_test.go
示例6: set
func set(t *testing.T, key, val string, ocas uint64, flags, exp uint32, ecas uint64, eerr error) {
ocas, err := cn.Set(key, val, 0, 0, 0)
assert.Equalf(t, eerr, err, "shouldn't be an error: %v", err)
if ecas != 0 {
assert.Equalf(t, ecas, ocas, "wrong CAS for get: %d != %d", ocas, ecas)
}
}
开发者ID:outdoorsy,项目名称:mc,代码行数:7,代码来源:utils_test.go
示例7: DoTestVisitDirsOnly
func DoTestVisitDirsOnly(t *testing.T, repo fs.NodeRepo) {
dir, errors := fs.IndexDir("../../testroot/", repo)
assert.T(t, dir != nil)
assert.Equalf(t, 0, len(errors), "%v", errors)
collect := []fs.Dir{}
visited := []fs.Node{}
fs.Walk(dir, func(node fs.Node) bool {
visited = append(visited, node)
d, ok := node.(fs.Dir)
if ok {
collect = append(collect, d)
return true
}
_, ok = node.(fs.File)
if ok {
return false
}
t.Errorf("Unexpected type during visit: %v", node)
return true
})
assert.Equalf(t, 3, len(collect), "Unexpected dirs in testroot/: %v", collect)
for _, node := range visited {
_, ok := node.(fs.Block)
if ok {
t.Fatalf("Should not have gotten a block, we told visitor to stop at file level.")
}
}
}
开发者ID:cmars,项目名称:replican-sync,代码行数:35,代码来源:test.go
示例8: TestMatchIdentity
// Test that the matcher matches all blocks in two identical files.
func TestMatchIdentity(t *testing.T) {
srcPath := "../../testroot/My Music/0 10k 30.mp4"
dstPath := srcPath
match, err := Match(srcPath, dstPath)
assert.Tf(t, err == nil, "%v", err)
nMatches := 0
for i, match := range match.BlockMatches {
assert.Equalf(t, int64(0), match.DstOffset%int64(fs.BLOCKSIZE),
"Destination match block# %d not aligned with blocksize! (offset=%d)",
i, match.DstOffset)
nMatches++
}
fileInfo, err := os.Stat(srcPath)
if fileInfo == nil {
t.Fatalf("Cannot stat file %s: ", err.String())
} else {
nExpectMatches := fileInfo.Size / int64(fs.BLOCKSIZE)
if fileInfo.Size%int64(fs.BLOCKSIZE) > 0 {
nExpectMatches++
}
assert.Equal(t, nExpectMatches, int64(nMatches))
}
lastBlockSize := fileInfo.Size - int64(match.BlockMatches[14].DstOffset)
assert.Equalf(t, int64(5419), lastBlockSize,
"Unxpected last block size: %d", lastBlockSize)
}
开发者ID:cmars,项目名称:replican-sync,代码行数:32,代码来源:match_test.go
示例9: TestUsageAfterMarshalRoundTrip
// Make sure that after roundtripping, an Hll is still usable and behaves identically.
func TestUsageAfterMarshalRoundTrip(t *testing.T) {
h := NewHll(10, 20)
h.Add(randUint64(t))
h.Add(randUint64(t))
h.Add(randUint64(t))
jBuf, err := json.Marshal(h)
assert.Equalf(t, nil, err, "%v", err)
rt := &Hll{}
err = json.Unmarshal(jBuf, rt)
assert.Equalf(t, nil, err, "%v", err)
for i := uint64(100); i < 1000; i++ {
r := randUint64(t)
rt.Add(r)
h.Add(r)
assert.Equalf(t, rt.isSparse, h.isSparse, "%v", i)
// fmt.Printf("2 calling rt.Cardinality(), rt.isSparse=%v\n", rt.isSparse)
rtCard := rt.Cardinality()
// fmt.Printf("3\n")
hCard := h.Cardinality()
assert.Equal(t, rtCard, hCard, i)
}
assert.T(t, !h.isSparse)
}
开发者ID:postfix,项目名称:hll,代码行数:30,代码来源:marshal_test.go
示例10: TestConnGrant
func TestConnGrant(t *testing.T) {
for _, tst := range grantTests {
ok := tst.c.grant(tst.sk)
assert.Equalf(t, tst.ok, ok, "%# v", pretty.Formatter(tst))
assert.Equalf(t, tst.r, tst.c.raccess, "%# v", pretty.Formatter(tst))
assert.Equalf(t, tst.w, tst.c.waccess, "%# v", pretty.Formatter(tst))
}
}
开发者ID:zyxar,项目名称:doozerd,代码行数:8,代码来源:conn_test.go
示例11: verifyLexerTokens
func verifyLexerTokens(t *testing.T, l *Lexer, tokens []Token) {
for _, goodToken := range tokens {
tok := l.NextToken()
//u.Debugf("%#v %#v", tok, goodToken)
assert.Equalf(t, tok.T, goodToken.T, "want='%v' has %v ", goodToken.T, tok.T)
assert.Equalf(t, tok.V, goodToken.V, "want='%v' has %v ", goodToken.V, tok.V)
}
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:8,代码来源:lexer_test.go
示例12: TestVersion
// Test the version command works...
func TestVersion(t *testing.T) {
testInit(t)
ver, err := cn.Version()
assert.Equalf(t, mcNil, err, "unexpected error: %v", err)
good, errRegex := regexp.MatchString("[0-9]+\\.[0-9]+\\.[0-9]+", ver)
assert.Equalf(t, nil, errRegex, "unexpected error: %v", errRegex)
assert.Equalf(t, good, true, "version of unexcpected form: %s", ver)
}
开发者ID:memcachier,项目名称:mc,代码行数:10,代码来源:mc_test.go
示例13: verifyJsonTokens
func verifyJsonTokens(t *testing.T, expString string, tokens []Token) {
l := NewJsonLexer(expString)
for i, goodToken := range tokens {
tok := l.NextToken()
//u.Debugf("%#v %#v", tok, goodToken)
assert.Equalf(t, tok.T, goodToken.T, "%d want token type ='%v' has %v ", i, goodToken.T, tok.T)
assert.Equalf(t, tok.V, goodToken.V, "%d want token value='%v' has %v ", i, goodToken.V, tok.V)
}
}
开发者ID:kyledj,项目名称:qlbridge,代码行数:9,代码来源:dialect_json_test.go
示例14: verifyTokens
func verifyTokens(t *testing.T, sql string, tokens []lex.Token) {
l := lex.NewLexer(sql, InfluxQlDialect)
for _, goodToken := range tokens {
tok := l.NextToken()
u.Debugf("%#v %#v", tok, goodToken)
assert.Equalf(t, tok.V, goodToken.V, "has='%v' want='%v'", tok.V, goodToken.V)
assert.Equalf(t, tok.T, goodToken.T, "has='%v' want='%v'", tok.V, goodToken.V)
}
}
开发者ID:kyledj,项目名称:qlbridge,代码行数:9,代码来源:parse_test.go
示例15: verifyExpr2Tokens
func verifyExpr2Tokens(t *testing.T, expString string, tokens []Token) {
l := NewLexer(expString, LogicalExpressionDialect)
for _, goodToken := range tokens {
tok := l.NextToken()
//u.Debugf("%#v %#v", tok, goodToken)
assert.Equalf(t, tok.T, goodToken.T, "want='%v' has %v ", goodToken.T, tok.T)
assert.Equalf(t, tok.V, goodToken.V, "want='%v' has %v ", goodToken.V, tok.V)
}
}
开发者ID:kyledj,项目名称:qlbridge,代码行数:9,代码来源:dialect_expr_test.go
示例16: verifyTokens
func verifyTokens(t *testing.T, sql string, tokens []Token) {
l := NewSqlLexer(sql)
u.Debugf("sql: %v", sql)
for _, goodToken := range tokens {
tok := l.NextToken()
//u.Debugf("%#v %#v", tok, goodToken)
assert.Equalf(t, tok.T, goodToken.T, "want='%v' has %v ", goodToken.T, tok.T)
assert.Equalf(t, tok.V, goodToken.V, "want='%v' has %v ", goodToken.V, tok.V)
}
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:10,代码来源:lexer_test.go
示例17: verifyFilterQLTokens
func verifyFilterQLTokens(t *testing.T, ql string, tokens []Token) {
l := NewFilterQLLexer(ql)
u.Debugf("filterql: %v", ql)
for _, goodToken := range tokens {
tok := l.NextToken()
//u.Debugf("%#v %#v", tok, goodToken)
assert.Equalf(t, tok.T, goodToken.T, "want='%v' has %v %v", goodToken.T, tok.T, l.PeekX(10))
assert.Equalf(t, tok.V, goodToken.V, "want='%v' has %v ", goodToken.V, tok.V)
}
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:10,代码来源:dialect_filterql_test.go
示例18: get
func get(t *testing.T, key, val string, ecas uint64, eerr error) {
v, ocas, _, err := cn.Get(key)
assert.Equalf(t, eerr, err, "shouldn't be an error: %v", err)
if eerr == nil && val != "" {
assert.Equalf(t, val, v, "wrong value: %v", v)
}
if ecas != 0 {
assert.Equalf(t, ecas, ocas, "wrong CAS for get: %d != %d", ocas, ecas)
}
}
开发者ID:outdoorsy,项目名称:mc,代码行数:10,代码来源:utils_test.go
示例19: TestConnPrepareErr
func TestConnPrepareErr(t *testing.T) {
nc, err := net.Dial("tcp", "localhost:5432")
assert.Equalf(t, nil, err, "%v", err)
cn, err := New(nc, map[string]string{"user": os.Getenv("USER")}, "")
assert.Equalf(t, nil, err, "%v", err)
_, err = cn.Prepare("SELECT length($1) AS ZOMG! AN ERR")
assert.NotEqual(t, nil, err)
}
开发者ID:zeebo,项目名称:pq.go,代码行数:10,代码来源:conn_test.go
示例20: DoTestPatchRenameScope
func DoTestPatchRenameScope(t *testing.T, mkrepo repoMaker) {
tg := treegen.New()
treeSpec := tg.D("foo",
tg.F("bar", tg.B(6806, 65536)),
tg.F("baz", tg.B(6806, 65536)))
srcpath := treegen.TestTree(t, treeSpec)
defer os.RemoveAll(srcpath)
srcRepo := mkrepo(t)
defer srcRepo.Close()
srcStore, err := fs.NewLocalStore(srcpath, srcRepo)
assert.T(t, err == nil)
tg = treegen.New()
treeSpec = tg.D("foo",
tg.F("baz", tg.B(6806, 65536)),
tg.F("blop", tg.B(6806, 65536)))
dstpath := treegen.TestTree(t, treeSpec)
defer os.RemoveAll(dstpath)
dstRepo := mkrepo(t)
defer dstRepo.Close()
dstStore, err := fs.NewLocalStore(dstpath, dstRepo)
assert.T(t, err == nil)
patchPlan := NewPatchPlan(srcStore, dstStore)
// printPlan(patchPlan)
failedCmd, err := patchPlan.Exec()
assert.Tf(t, failedCmd == nil && err == nil, "%v: %v", failedCmd, err)
// The actual content of dst after the patch depends on
// which file the repo chooses when matching foo/bar
// to baz or blop in dst.
//
// If blop matches, it will get renamed to bar and the trees will
// become identical. However if baz matches, blop will be left in place.
srcDir, errors := fs.IndexDir(srcpath, fs.NewMemRepo())
assert.Equalf(t, 0, len(errors), "%v", errors)
dstDir, errors := fs.IndexDir(dstpath, fs.NewMemRepo())
assert.Equalf(t, 0, len(errors), "%v", errors)
for _, path := range []string{"foo/bar", "foo/baz"} {
srcNode, has := fs.Lookup(srcDir, path)
assert.T(t, has)
dstNode, has := fs.Lookup(dstDir, path)
assert.T(t, has)
assert.Equal(t,
srcNode.(fs.File).Info().Strong,
dstNode.(fs.File).Info().Strong)
}
}
开发者ID:cmars,项目名称:replican-sync,代码行数:54,代码来源:patch_test.go
注:本文中的github.com/bmizerany/assert.Equalf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论