本文整理汇总了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)
//.........这里部分代码省略.........