本文整理汇总了Golang中github.com/cockroachdb/cockroach/util.Tester.Errorf方法的典型用法代码示例。如果您正苦于以下问题:Golang Tester.Errorf方法的具体用法?Golang Tester.Errorf怎么用?Golang Tester.Errorf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/util.Tester
的用法示例。
在下文中一共展示了Tester.Errorf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CheckKVs
// CheckKVs verifies that a KeyValue slice contains the expected keys and values. The values can be
// either integers or strings; the expected results are passed as alternating keys and values, e.g:
// checkScanResult(t, result, key1, val1, key2, val2)
func CheckKVs(t util.Tester, kvs []KeyValue, expected ...interface{}) {
expLen := len(expected) / 2
if expLen != len(kvs) {
t.Errorf("%s: expected %d scan results, got %d", errInfo(), expLen, len(kvs))
return
}
for i := 0; i < expLen; i++ {
expKey := expected[2*i].(roachpb.Key)
if key := kvs[i].Key; !key.Equal(expKey) {
t.Errorf("%s: expected scan key %d to be %q; got %q", errInfo(), i, expKey, key)
}
switch expValue := expected[2*i+1].(type) {
case int:
if value, err := kvs[i].Value.GetInt(); err != nil {
t.Errorf("%s: non-integer scan value %d: %q", errInfo(), i, kvs[i].Value)
} else if value != int64(expValue) {
t.Errorf("%s: expected scan value %d to be %d; got %d",
errInfo(), i, expValue, value)
}
case string:
if value := kvs[i].Value.String(); value != expValue {
t.Errorf("%s: expected scan value %d to be %s; got %s",
errInfo(), i, expValue, value)
}
default:
panic(fmt.Sprintf("unsupported type %T", expValue))
}
}
}
示例2: CheckKeysInKVs
// CheckKeysInKVs verifies that a KeyValue slice contains the given keys.
func CheckKeysInKVs(t util.Tester, kvs []KeyValue, keys ...string) {
if len(keys) != len(kvs) {
t.Errorf("%s: expected %d scan results, got %d", errInfo(), len(keys), len(kvs))
return
}
for i, kv := range kvs {
expKey := keys[i]
if key := string(kv.Key); key != keys[i] {
t.Errorf("%s: expected scan key %d to be %q; got %q", errInfo(), i, expKey, key)
}
}
}