本文整理汇总了Golang中github.com/karlseguin/nabu/key.Type函数的典型用法代码示例。如果您正苦于以下问题:Golang Type函数的具体用法?Golang Type怎么用?Golang Type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestEmptyLength
func TestEmptyLength(t *testing.T) {
spec := gspec.New(t)
empty := NewEmpty("x")
empty.Set(key.Type(4))
empty.Set(key.Type(6))
spec.Expect(empty.Len()).ToEqual(0)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:empty_test.go
示例2: TestLoadsTheMap
func TestLoadsTheMap(t *testing.T) {
spec := gspec.New(t)
m := newIdMap()
data := map[uint]string{1: "a1", 2: "b2", 10: "c3"}
m.load(data)
spec.Expect(m.get("c3", false)).ToEqual(key.Type(10))
spec.Expect(m.get("c4", true)).ToEqual(key.Type(11))
}
开发者ID:Wexcode,项目名称:nabu,代码行数:8,代码来源:idmap_test.go
示例3: TestSortedStringsOrderOnRemove
func TestSortedStringsOrderOnRemove(t *testing.T) {
spec := gspec.New(t)
s := NewSortedStrings("test")
sortedSetLoad(s, 1, "banana", 2, "apples", 3, "oranges")
s.Remove(key.Type(3))
spec.Expect(s.list[1].id).ToEqual(key.Type(2))
spec.Expect(s.list[2].id).ToEqual(key.Type(1))
spec.Expect(s.Len()).ToEqual(2)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:9,代码来源:sortedstrings_test.go
示例4: TestSortedStringsContains
func TestSortedStringsContains(t *testing.T) {
spec := gspec.New(t)
s := NewSortedStrings("test")
sortedSetLoad(s, 1, "banana", 2, "apples", 3, "oranges")
s.SetString(key.Type(1), "prune")
s.SetString(key.Type(4), "apes")
s.Remove(1)
spec.Expect(s.Contains(key.Type(1))).ToEqual(false)
spec.Expect(s.Contains(key.Type(3))).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:10,代码来源:sortedstrings_test.go
示例5: TestSortedIntsForwardIterationMovesUpToNextClosest
func TestSortedIntsForwardIterationMovesUpToNextClosest(t *testing.T) {
for i := 0; i < 1000; i++ {
rand.Seed(int64(i))
s := NewSortedInts("test")
s.SetInt(key.Type(1), 1)
s.SetInt(key.Type(3), 3)
s.SetInt(key.Type(4), 4)
s.SetInt(key.Type(5), 5)
assertIterator(t, s.Forwards().Range(2, 4).Offset(0), 3, 4)
}
}
开发者ID:Wexcode,项目名称:nabu,代码行数:11,代码来源:sortedints_test.go
示例6: get
func (m *IdMap) get(s string, create bool) key.Type {
bucket := m.getBucket(s)
bucket.RLock()
id, exists := bucket.lookup[s]
bucket.RUnlock()
if exists {
return id
}
if create == false {
return key.NULL
}
bucket.Lock()
defer bucket.Unlock()
id, exists = bucket.lookup[s]
if exists {
return id
}
id = key.Type(atomic.AddUint64(&m.counter, 1))
bucket.lookup[s] = id
return id
}
开发者ID:Wexcode,项目名称:nabu,代码行数:25,代码来源:idmap.go
示例7: TestEmptyBackwards
func TestEmptyBackwards(t *testing.T) {
spec := gspec.New(t)
empty := NewEmpty("x")
empty.Set(key.Type(4))
iter := empty.Backwards()
spec.Expect(iter.Current()).ToEqual(key.NULL)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:empty_test.go
示例8: TestIdMapReturnsAnExistingId
func TestIdMapReturnsAnExistingId(t *testing.T) {
spec := gspec.New(t)
m := newIdMap()
m.get("over", true)
m.get("9000", true)
spec.Expect(m.get("over", false)).ToEqual(key.Type(1))
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:idmap_test.go
示例9: TestUnionDoesNotContainANonExistantId
func TestUnionDoesNotContainANonExistantId(t *testing.T) {
spec := gspec.New(t)
union := NewUnion("x", []string{"apple", "orange"})
union.On(makeSetIndex(20, 23, 24, 25, 26))
union.On(makeSetIndex(20, 25, 28, 29))
spec.Expect(union.Contains(key.Type(22))).ToEqual(false)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:union_test.go
示例10: makeSetIndex
func makeSetIndex(ids ...int) indexes.Index {
set := indexes.NewSetString("test")
for _, id := range ids {
set.Set(key.Type(id))
}
return set
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:set_test.go
示例11: TestSetContainsAnExistingIdIfMultipleIndexesContainsIt
func TestSetContainsAnExistingIdIfMultipleIndexesContainsIt(t *testing.T) {
spec := gspec.New(t)
union := NewUnion("x", []string{"apple", "orange"})
union.On(makeSetIndex(20, 23, 24, 25, 26))
union.On(makeSetIndex(20, 25, 28, 29))
spec.Expect(union.Contains(key.Type(20))).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:union_test.go
示例12: TestGreaterThanOrEqualContainsAnIdWithAScoreEqualToOurTarget
func TestGreaterThanOrEqualContainsAnIdWithAScoreEqualToOurTarget(t *testing.T) {
spec := gspec.New(t)
gte := NewGreaterThanOrEqual("x", 10)
gte.On(makeIndex(1, 7, 8, 10, 11, 12, 13, 20))
score, exists := gte.Score(key.Type(3))
spec.Expect(score).ToEqual(10)
spec.Expect(exists).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:8,代码来源:greaterthanorequal_test.go
示例13: TestEqualContainsAnIdWithAScoreEqualOurTarget
func TestEqualContainsAnIdWithAScoreEqualOurTarget(t *testing.T) {
spec := gspec.New(t)
eq := NewEqual("x", 10)
eq.On(makeIndex(1, 7, 8, 10, 11, 12, 13, 20))
score, exists := eq.Score(key.Type(3))
spec.Expect(score).ToEqual(10)
spec.Expect(exists).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:8,代码来源:equal_test.go
示例14: TestLessThanOrEqualContainsAnIdWithAScoreLessThanOrEqualOurTarget
func TestLessThanOrEqualContainsAnIdWithAScoreLessThanOrEqualOurTarget(t *testing.T) {
spec := gspec.New(t)
lte := NewLessThanOrEqual("x", 10)
lte.On(makeIndex(1, 7, 8, 10, 11, 12, 13, 20))
score, exists := lte.Score(key.Type(2))
spec.Expect(score).ToEqual(8)
spec.Expect(exists).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:8,代码来源:lessthanorequal_test.go
示例15: TestEqualReturnsTheLength
func TestEqualReturnsTheLength(t *testing.T) {
spec := gspec.New(t)
eq := NewEqual("x", 10)
idx := makeIndex(1, 7, 8, 10, 11, 12, 13, 20)
idx.(indexes.WithIntScores).SetInt(key.Type(22), 10)
eq.On(idx)
spec.Expect(eq.Len()).ToEqual(2)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:8,代码来源:equal_test.go
示例16: TestBetweenContainsAnIdWithAScoreWithinOurTarget
func TestBetweenContainsAnIdWithAScoreWithinOurTarget(t *testing.T) {
spec := gspec.New(t)
bt := NewBetween("x", 7, 11)
bt.On(makeIndex(1, 7, 8, 10, 11, 12, 13, 20))
score, exists := bt.Score(key.Type(3))
spec.Expect(score).ToEqual(10)
spec.Expect(exists).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:8,代码来源:between_test.go
示例17: TestBetweenReturnsTheLength
func TestBetweenReturnsTheLength(t *testing.T) {
spec := gspec.New(t)
bt := NewBetween("x", 7, 11)
idx := makeIndex(1, 7, 8, 10, 11, 12, 13, 20)
idx.(indexes.WithIntScores).SetInt(key.Type(22), 10)
bt.On(idx)
spec.Expect(bt.Len()).ToEqual(5)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:8,代码来源:between_test.go
示例18: TestMetaCanBeSetWithStringId
func TestMetaCanBeSetWithStringId(t *testing.T) {
spec := gspec.New(t)
meta := newMeta(SmallDB(), false)
spec.Expect(meta.IsUpdate).ToEqual(false)
spec.Expect(meta.StringId("123aa")).ToEqual(uint(1))
id, stringId := meta.getId()
spec.Expect(id).ToEqual(key.Type(1))
spec.Expect(stringId).ToEqual("123aa")
}
开发者ID:Wexcode,项目名称:nabu,代码行数:9,代码来源:document_test.go
示例19: TestSetCanDeleteItem
func TestSetCanDeleteItem(t *testing.T) {
s := NewSetString("test")
setLoad(s, 1, 2, 3, 4, 5, 6, 7, 8, 9)
s.Remove(3)
s.Remove(6)
s.Remove(22)
s.Set(key.Type(3))
assertIterator(t, s.Backwards(), 3, 9, 8, 7, 5, 4, 2, 1)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:9,代码来源:setstring_test.go
示例20: assertIterator
func assertIterator(t *testing.T, iterator Iterator, ids ...key.Type) {
defer iterator.Close()
spec := gspec.New(t)
i := 0
for id := iterator.Current(); id != key.NULL; id = iterator.Next() {
spec.Expect(id).ToEqual(key.Type(ids[i]))
i++
}
}
开发者ID:Wexcode,项目名称:nabu,代码行数:9,代码来源:sortedints_test.go
注:本文中的github.com/karlseguin/nabu/key.Type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论