本文整理匯總了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)
}
}
}