本文整理匯總了Golang中testing.T.secondaryValues方法的典型用法代碼示例。如果您正苦於以下問題:Golang T.secondaryValues方法的具體用法?Golang T.secondaryValues怎麽用?Golang T.secondaryValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類testing.T
的用法示例。
在下文中一共展示了T.secondaryValues方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestIndexKey
func TestIndexKey(t *testing.T) {
rng, _ := randutil.NewPseudoRand()
var a DatumAlloc
tests := []indexKeyTest{
{nil, nil,
[]parser.Datum{parser.NewDInt(10)},
[]parser.Datum{parser.NewDInt(20)},
},
{[]ID{100}, nil,
[]parser.Datum{parser.NewDInt(10), parser.NewDInt(11)},
[]parser.Datum{parser.NewDInt(20)},
},
{[]ID{100, 200}, nil,
[]parser.Datum{parser.NewDInt(10), parser.NewDInt(11), parser.NewDInt(12)},
[]parser.Datum{parser.NewDInt(20)},
},
{nil, []ID{100},
[]parser.Datum{parser.NewDInt(10)},
[]parser.Datum{parser.NewDInt(20), parser.NewDInt(21)},
},
{[]ID{100}, []ID{100},
[]parser.Datum{parser.NewDInt(10), parser.NewDInt(11)},
[]parser.Datum{parser.NewDInt(20), parser.NewDInt(21)},
},
{[]ID{100}, []ID{200},
[]parser.Datum{parser.NewDInt(10), parser.NewDInt(11)},
[]parser.Datum{parser.NewDInt(20), parser.NewDInt(21)},
},
{[]ID{100, 200}, []ID{100, 300},
[]parser.Datum{parser.NewDInt(10), parser.NewDInt(11), parser.NewDInt(12)},
[]parser.Datum{parser.NewDInt(20), parser.NewDInt(21), parser.NewDInt(22)},
},
}
for i := 0; i < 1000; i++ {
var t indexKeyTest
t.primaryInterleaves = make([]ID, rng.Intn(10))
for j := range t.primaryInterleaves {
t.primaryInterleaves[j] = ID(1 + rng.Intn(10))
}
valuesLen := randutil.RandIntInRange(rng, len(t.primaryInterleaves)+1, len(t.primaryInterleaves)+10)
t.primaryValues = make([]parser.Datum, valuesLen)
for j := range t.primaryValues {
t.primaryValues[j] = RandDatum(rng, ColumnType{Kind: ColumnType_INT}, true)
}
t.secondaryInterleaves = make([]ID, rng.Intn(10))
for j := range t.secondaryInterleaves {
t.secondaryInterleaves[j] = ID(1 + rng.Intn(10))
}
valuesLen = randutil.RandIntInRange(rng, len(t.secondaryInterleaves)+1, len(t.secondaryInterleaves)+10)
t.secondaryValues = make([]parser.Datum, valuesLen)
for j := range t.secondaryValues {
t.secondaryValues[j] = RandDatum(rng, ColumnType{Kind: ColumnType_INT}, true)
}
tests = append(tests, t)
}
for i, test := range tests {
tableDesc, colMap := makeTableDescForTest(test)
testValues := append(test.primaryValues, test.secondaryValues...)
primaryKeyPrefix := MakeIndexKeyPrefix(&tableDesc, tableDesc.PrimaryIndex.ID)
primaryKey, _, err := EncodeIndexKey(
&tableDesc, &tableDesc.PrimaryIndex, colMap, testValues, primaryKeyPrefix)
if err != nil {
t.Fatal(err)
}
primaryValue := roachpb.MakeValueFromBytes(nil)
primaryIndexKV := client.KeyValue{Key: primaryKey, Value: &primaryValue}
secondaryIndexEntry, err := EncodeSecondaryIndex(
&tableDesc, &tableDesc.Indexes[0], colMap, testValues)
if err != nil {
t.Fatal(err)
}
secondaryIndexKV := client.KeyValue{
Key: secondaryIndexEntry.Key,
Value: &secondaryIndexEntry.Value,
}
checkEntry := func(index *IndexDescriptor, entry client.KeyValue) {
values, err := decodeIndex(&a, &tableDesc, index, entry.Key)
if err != nil {
t.Fatal(err)
}
for j, value := range values {
testValue := testValues[colMap[index.ColumnIDs[j]]]
if value.Compare(testValue) != 0 {
t.Fatalf("%d: value %d got %q but expected %q", i, j, value, testValue)
}
}
indexID, _, err := DecodeIndexKeyPrefix(&a, &tableDesc, entry.Key)
if err != nil {
t.Fatal(err)
//.........這裏部分代碼省略.........