本文整理汇总了Golang中github.com/attic-labs/testify/assert.True函数的典型用法代码示例。如果您正苦于以下问题:Golang True函数的具体用法?Golang True怎么用?Golang True使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了True函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestTwoClientsWithEmptyDataset
func TestTwoClientsWithEmptyDataset(t *testing.T) {
assert := assert.New(t)
id1 := "testdataset"
cs := chunks.NewMemoryStore()
dsx := newDS(id1, cs)
dsy := newDS(id1, cs)
// dsx: || -> |a|
a := types.String("a")
dsx, err := dsx.CommitValue(a)
assert.NoError(err)
assert.True(dsx.Head().Get(datas.ValueField).Equals(a))
// dsy: || -> |b|
_, ok := dsy.MaybeHead()
assert.False(ok)
b := types.String("b")
dsy, err = dsy.CommitValue(b)
assert.Error(err)
// Commit failed, but ds1 now has latest head, so we should be able to just try again.
// dsy: |a| -> |b|
dsy, err = dsy.CommitValue(b)
assert.NoError(err)
assert.True(dsy.Head().Get(datas.ValueField).Equals(b))
}
开发者ID:Richardphp,项目名称:noms,代码行数:26,代码来源:dataset_test.go
示例2: TestConstructQueryString
func TestConstructQueryString(t *testing.T) {
assert := assert.New(t)
prefix := "TestConstructQueryString"
d1, e1 := ioutil.TempDir(os.TempDir(), prefix)
defer os.RemoveAll(d1)
d2, e2 := ioutil.TempDir(os.TempDir(), prefix)
defer os.RemoveAll(d2)
assert.NoError(e1)
assert.NoError(e2)
qs, stores := constructQueryString([]string{
"foo=bar",
"store1=ldb:" + d1,
"store2=ldb:" + d2,
"store3=ldb:" + d1,
"hello=world",
})
assert.Equal(5, len(qs))
assert.Equal("bar", qs.Get("foo"))
assert.True(strings.HasPrefix(qs.Get("store1"), dsPathPrefix))
assert.True(strings.HasPrefix(qs.Get("store2"), dsPathPrefix))
assert.True(strings.HasPrefix(qs.Get("store3"), dsPathPrefix))
assert.Equal(qs.Get("store1"), qs.Get("store3"))
assert.NotEqual(qs.Get("store1"), qs.Get("store2"))
assert.Equal(2, len(stores))
}
开发者ID:Richardphp,项目名称:noms,代码行数:29,代码来源:noms_ui_test.go
示例3: TestTotalOrdering
func TestTotalOrdering(t *testing.T) {
assert := assert.New(t)
// values in increasing order. Some of these are compared by ref so changing the serialization might change the ordering.
values := []Value{
Bool(false), Bool(true),
Number(-10), Number(0), Number(10),
String("a"), String("b"), String("c"),
// The order of these are done by the hash.
NewSet(Number(0), Number(1), Number(2), Number(3)),
BoolType,
// Value - values cannot be value
// Cycle - values cannot be cycle
// Union - values cannot be unions
}
for i, vi := range values {
for j, vj := range values {
if i == j {
assert.True(vi.Equals(vj))
} else if i < j {
x := vi.Less(vj)
assert.True(x)
} else {
x := vi.Less(vj)
assert.False(x)
}
}
}
}
开发者ID:Richardphp,项目名称:noms,代码行数:32,代码来源:compare_test.go
示例4: TestTypes
func TestTypes(t *testing.T) {
assert := assert.New(t)
vs := NewTestValueStore()
mapType := MakeMapType(StringType, NumberType)
setType := MakeSetType(StringType)
mahType := MakeStructType("MahStruct",
[]string{"Field1", "Field2"},
[]*Type{
StringType,
BoolType,
},
)
recType := MakeStructType("RecursiveStruct", []string{"self"}, []*Type{MakeCycleType(0)})
mRef := vs.WriteValue(mapType).TargetHash()
setRef := vs.WriteValue(setType).TargetHash()
mahRef := vs.WriteValue(mahType).TargetHash()
recRef := vs.WriteValue(recType).TargetHash()
assert.True(mapType.Equals(vs.ReadValue(mRef)))
assert.True(setType.Equals(vs.ReadValue(setRef)))
assert.True(mahType.Equals(vs.ReadValue(mahRef)))
assert.True(recType.Equals(vs.ReadValue(recRef)))
}
开发者ID:Richardphp,项目名称:noms,代码行数:25,代码来源:type_test.go
示例5: TestSetHas2
func TestSetHas2(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
smallTestChunks()
defer normalProductionChunks()
assert := assert.New(t)
vs := NewTestValueStore()
doTest := func(ts testSet) {
set := ts.toSet()
set2 := vs.ReadValue(vs.WriteValue(set).TargetHash()).(Set)
for _, v := range ts {
assert.True(set.Has(v))
assert.True(set2.Has(v))
}
diffSetTest(assert, set, set2, 0, 0)
}
doTest(getTestNativeOrderSet(16))
doTest(getTestRefValueOrderSet(2))
doTest(getTestRefToNativeOrderSet(2, vs))
doTest(getTestRefToValueOrderSet(2, vs))
}
开发者ID:Richardphp,项目名称:noms,代码行数:26,代码来源:set_test.go
示例6: SkipTestIncrementalAddRef
func SkipTestIncrementalAddRef(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewTestStore()
vs := newLocalValueStore(cs)
expectedItem := Number(42)
ref := vs.WriteValue(expectedItem)
expected := NewList(ref)
ref = vs.WriteValue(expected)
actualVar := vs.ReadValue(ref.TargetHash())
assert.Equal(1, cs.Reads)
assert.True(expected.Equals(actualVar))
actual := actualVar.(List)
actualItem := actual.Get(0)
assert.Equal(2, cs.Reads)
assert.True(expectedItem.Equals(actualItem))
// do it again to make sure caching works.
actualItem = actual.Get(0)
assert.Equal(2, cs.Reads)
assert.True(expectedItem.Equals(actualItem))
}
开发者ID:willhite,项目名称:noms-old,代码行数:25,代码来源:incremental_test.go
示例7: TestTypes
func TestTypes(t *testing.T) {
assert := assert.New(t)
vs := NewTestValueStore()
mapType := MakeMapType(StringType, NumberType)
setType := MakeSetType(StringType)
mahType := MakeStructType("MahStruct", TypeMap{
"Field1": StringType,
"Field2": BoolType,
})
recType := MakeStructType("RecursiveStruct", TypeMap{
"self": nil,
})
recType.Desc.(StructDesc).SetField("self", recType)
mRef := vs.WriteValue(mapType).TargetHash()
setRef := vs.WriteValue(setType).TargetHash()
mahRef := vs.WriteValue(mahType).TargetHash()
recRef := vs.WriteValue(recType).TargetHash()
assert.True(mapType.Equals(vs.ReadValue(mRef)))
assert.True(setType.Equals(vs.ReadValue(setRef)))
assert.True(mahType.Equals(vs.ReadValue(mahRef)))
assert.True(recType.Equals(vs.ReadValue(recRef)))
}
开发者ID:willhite,项目名称:noms-old,代码行数:25,代码来源:type_test.go
示例8: TestStreamingListCreation
func TestStreamingListCreation(t *testing.T) {
smallTestChunks()
defer normalProductionChunks()
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
assert := assert.New(t)
vs := NewTestValueStore()
simpleList := getTestList()
cl := NewList(simpleList...)
valueChan := make(chan Value)
listChan := NewStreamingList(vs, valueChan)
for _, v := range simpleList {
valueChan <- v
}
close(valueChan)
sl := <-listChan
assert.True(cl.Equals(sl))
cl.Iter(func(v Value, idx uint64) (done bool) {
done = !assert.True(v.Equals(sl.Get(idx)))
return
})
}
开发者ID:Richardphp,项目名称:noms,代码行数:26,代码来源:list_test.go
示例9: TestListTypeAfterMutations
func TestListTypeAfterMutations(t *testing.T) {
smallTestChunks()
defer normalProductionChunks()
assert := assert.New(t)
test := func(n int, c interface{}) {
values := generateNumbersAsValues(n)
l := NewList(values...)
assert.Equal(l.Len(), uint64(n))
assert.IsType(c, l.sequence())
assert.True(l.Type().Equals(MakeListType(NumberType)))
l = l.Append(String("a"))
assert.Equal(l.Len(), uint64(n+1))
assert.IsType(c, l.sequence())
assert.True(l.Type().Equals(MakeListType(MakeUnionType(NumberType, StringType))))
l = l.Splice(l.Len()-1, 1)
assert.Equal(l.Len(), uint64(n))
assert.IsType(c, l.sequence())
assert.True(l.Type().Equals(MakeListType(NumberType)))
}
test(15, listLeafSequence{})
test(1500, indexedMetaSequence{})
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:list_test.go
示例10: TestMapIter2
func TestMapIter2(t *testing.T) {
assert := assert.New(t)
smallTestChunks()
defer normalProductionChunks()
doTest := func(tm testMap) {
m := tm.toMap()
sort.Sort(tm.entries)
idx := uint64(0)
endAt := uint64(64)
m.Iter(func(k, v Value) (done bool) {
assert.True(tm.entries[idx].key.Equals(k))
assert.True(tm.entries[idx].value.Equals(v))
if idx == endAt {
done = true
}
idx++
return
})
assert.Equal(endAt, idx-1)
}
doTest(getTestNativeOrderMap(16))
doTest(getTestRefValueOrderMap(2))
doTest(getTestRefToNativeOrderMap(2, NewTestValueStore()))
doTest(getTestRefToValueOrderMap(2, NewTestValueStore()))
}
开发者ID:Richardphp,项目名称:noms,代码行数:30,代码来源:map_test.go
示例11: TestMapIterAll
func TestMapIterAll(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
smallTestChunks()
defer normalProductionChunks()
assert := assert.New(t)
doTest := func(tm testMap) {
m := tm.toMap()
sort.Sort(tm.entries)
idx := uint64(0)
m.IterAll(func(k, v Value) {
assert.True(tm.entries[idx].key.Equals(k))
assert.True(tm.entries[idx].value.Equals(v))
idx++
})
}
doTest(getTestNativeOrderMap(16))
doTest(getTestRefValueOrderMap(2))
doTest(getTestRefToNativeOrderMap(2, NewTestValueStore()))
doTest(getTestRefToValueOrderMap(2, NewTestValueStore()))
}
开发者ID:Richardphp,项目名称:noms,代码行数:27,代码来源:map_test.go
示例12: TestMapHas
func TestMapHas(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
smallTestChunks()
defer normalProductionChunks()
assert := assert.New(t)
vs := NewTestValueStore()
doTest := func(tm testMap) {
m := tm.toMap()
m2 := vs.ReadValue(vs.WriteValue(m).TargetHash()).(Map)
for _, entry := range tm.entries {
k, v := entry.key, entry.value
assert.True(m.Has(k))
assert.True(m.Get(k).Equals(v))
assert.True(m2.Has(k))
assert.True(m2.Get(k).Equals(v))
}
diffMapTest(assert, m, m2, 0, 0, 0)
}
doTest(getTestNativeOrderMap(16))
doTest(getTestRefValueOrderMap(2))
doTest(getTestRefToNativeOrderMap(2, vs))
doTest(getTestRefToValueOrderMap(2, vs))
}
开发者ID:Richardphp,项目名称:noms,代码行数:29,代码来源:map_test.go
示例13: TestMapMaybeGet
func TestMapMaybeGet(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
smallTestChunks()
defer normalProductionChunks()
assert := assert.New(t)
doTest := func(tm testMap) {
m := tm.toMap()
for _, entry := range tm.entries {
v, ok := m.MaybeGet(entry.key)
if assert.True(ok, "%v should have been in the map!", entry.key) {
assert.True(v.Equals(entry.value), "%v != %v", v, entry.value)
}
}
_, ok := m.MaybeGet(tm.knownBadKey)
assert.False(ok, "m should not contain %v", tm.knownBadKey)
}
doTest(getTestNativeOrderMap(2))
doTest(getTestRefValueOrderMap(2))
doTest(getTestRefToNativeOrderMap(2, NewTestValueStore()))
doTest(getTestRefToValueOrderMap(2, NewTestValueStore()))
}
开发者ID:Richardphp,项目名称:noms,代码行数:27,代码来源:map_test.go
示例14: TestReadToMap
func TestReadToMap(t *testing.T) {
assert := assert.New(t)
ds := datas.NewDatabase(chunks.NewMemoryStore())
dataString := `a,1,true
b,2,false
`
r := NewCSVReader(bytes.NewBufferString(dataString), ',')
headers := []string{"A", "B", "C"}
kinds := KindSlice{types.StringKind, types.NumberKind, types.BoolKind}
m := ReadToMap(r, headers, 0, kinds, ds)
assert.Equal(uint64(2), m.Len())
assert.True(m.Type().Equals(
types.MakeMapType(types.StringType, types.MakeStructType("", map[string]*types.Type{
"B": types.NumberType,
"C": types.BoolType,
}))))
assert.True(m.Get(types.String("a")).Equals(types.NewStruct("", map[string]types.Value{
"B": types.Number(1),
"C": types.Bool(true),
})))
assert.True(m.Get(types.String("b")).Equals(types.NewStruct("", map[string]types.Value{
"B": types.Number(2),
"C": types.Bool(false),
})))
}
开发者ID:willhite,项目名称:noms-old,代码行数:29,代码来源:read_test.go
示例15: TestListRemoveAtMiddle
func TestListRemoveAtMiddle(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
assert := assert.New(t)
smallTestChunks()
defer normalProductionChunks()
cl := getTestList().toList()
cl2 := cl.RemoveAt(100)
cl3 := cl2.RemoveAt(200)
expected := getTestList()
assert.Equal(expected, testListFromNomsList(cl))
assert.Equal(getTestListLen(), cl.Len())
assert.True(expected.toList().Equals(cl))
expected = expected.RemoveAt(100)
assert.Equal(expected, testListFromNomsList(cl2))
assert.Equal(getTestListLen()-1, cl2.Len())
assert.True(expected.toList().Equals(cl2))
expected = expected.RemoveAt(200)
assert.Equal(expected, testListFromNomsList(cl3))
assert.Equal(getTestListLen()-2, cl3.Len())
assert.True(expected.toList().Equals(cl3))
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:list_test.go
示例16: TestCursorGetMaxNPrevItemsWithSingleItemSequence
func TestCursorGetMaxNPrevItemsWithSingleItemSequence(t *testing.T) {
assert := assert.New(t)
cur := newTestSequenceCursor([]interface{}{[]interface{}{100}, []interface{}{101}, []interface{}{102}})
assert.Equal([]sequenceItem{}, cur.maxNPrevItems(0))
assert.Equal([]sequenceItem{}, cur.maxNPrevItems(1))
assert.Equal([]sequenceItem{}, cur.maxNPrevItems(2))
assert.Equal([]sequenceItem{}, cur.maxNPrevItems(3))
assert.Equal(0, cur.idx)
assert.True(cur.advance())
assert.Equal([]sequenceItem{}, cur.maxNPrevItems(0))
assert.Equal([]sequenceItem{100}, cur.maxNPrevItems(1))
assert.Equal([]sequenceItem{100}, cur.maxNPrevItems(2))
assert.Equal([]sequenceItem{100}, cur.maxNPrevItems(3))
assert.Equal(0, cur.idx)
assert.True(cur.advance())
assert.Equal([]sequenceItem{}, cur.maxNPrevItems(0))
assert.Equal([]sequenceItem{101}, cur.maxNPrevItems(1))
assert.Equal([]sequenceItem{100, 101}, cur.maxNPrevItems(2))
assert.Equal([]sequenceItem{100, 101}, cur.maxNPrevItems(3))
assert.Equal(0, cur.idx)
assert.False(cur.advance())
assert.Equal([]sequenceItem{102}, cur.maxNPrevItems(1))
assert.Equal([]sequenceItem{101, 102}, cur.maxNPrevItems(2))
assert.Equal([]sequenceItem{100, 101, 102}, cur.maxNPrevItems(3))
assert.Equal([]sequenceItem{100, 101, 102}, cur.maxNPrevItems(4))
assert.Equal(1, cur.idx)
}
开发者ID:willhite,项目名称:noms-old,代码行数:31,代码来源:sequence_cursor_test.go
示例17: TestMapTypeAfterMutations
func TestMapTypeAfterMutations(t *testing.T) {
assert := assert.New(t)
test := func(n int, c interface{}) {
values := make([]Value, 2*n)
for i := 0; i < n; i++ {
values[2*i] = Number(i)
values[2*i+1] = Number(i)
}
m := NewMap(values...)
assert.Equal(m.Len(), uint64(n))
assert.IsType(c, m.sequence())
assert.True(m.Type().Equals(MakeMapType(NumberType, NumberType)))
m = m.Set(String("a"), String("a"))
assert.Equal(m.Len(), uint64(n+1))
assert.IsType(c, m.sequence())
assert.True(m.Type().Equals(MakeMapType(MakeUnionType(NumberType, StringType), MakeUnionType(NumberType, StringType))))
m = m.Remove(String("a"))
assert.Equal(m.Len(), uint64(n))
assert.IsType(c, m.sequence())
assert.True(m.Type().Equals(MakeMapType(NumberType, NumberType)))
}
test(10, mapLeafSequence{})
test(1000, orderedMetaSequence{})
}
开发者ID:Richardphp,项目名称:noms,代码行数:29,代码来源:map_test.go
示例18: TestHintsOnCache
func TestHintsOnCache(t *testing.T) {
assert := assert.New(t)
cvs := newLocalValueStore(chunks.NewTestStore())
cr1 := cvs.WriteValue(Number(1))
cr2 := cvs.WriteValue(Number(2))
s1 := NewStruct("", structData{
"a": cr1,
"b": cr2,
})
r := cvs.WriteValue(s1)
v := cvs.ReadValue(r.TargetHash())
if assert.True(v.Equals(s1)) {
cr3 := cvs.WriteValue(Number(3))
s2 := NewStruct("", structData{
"a": cr1,
"b": cr2,
"c": cr3,
})
hints := cvs.chunkHintsFromCache(s2)
if assert.Len(hints, 1) {
for _, hash := range []hash.Hash{r.TargetHash()} {
_, present := hints[hash]
assert.True(present)
}
}
}
}
开发者ID:willhite,项目名称:noms-old,代码行数:30,代码来源:value_store_test.go
示例19: TestSetTypeAfterMutations
func TestSetTypeAfterMutations(t *testing.T) {
assert := assert.New(t)
smallTestChunks()
defer normalProductionChunks()
test := func(n int, c interface{}) {
values := generateNumbersAsValues(n)
s := NewSet(values...)
assert.Equal(s.Len(), uint64(n))
assert.IsType(c, s.sequence())
assert.True(s.Type().Equals(MakeSetType(NumberType)))
s = s.Insert(String("a"))
assert.Equal(s.Len(), uint64(n+1))
assert.IsType(c, s.sequence())
assert.True(s.Type().Equals(MakeSetType(MakeUnionType(NumberType, StringType))))
s = s.Remove(String("a"))
assert.Equal(s.Len(), uint64(n))
assert.IsType(c, s.sequence())
assert.True(s.Type().Equals(MakeSetType(NumberType)))
}
test(10, setLeafSequence{})
test(2000, orderedMetaSequence{})
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:set_test.go
示例20: TestSetUniqueKeysString
func TestSetUniqueKeysString(t *testing.T) {
assert := assert.New(t)
s1 := NewSet(String("hello"), String("world"), String("hello"))
assert.Equal(uint64(2), s1.Len())
assert.True(s1.Has(String("hello")))
assert.True(s1.Has(String("world")))
assert.False(s1.Has(String("foo")))
}
开发者ID:Richardphp,项目名称:noms,代码行数:8,代码来源:set_test.go
注:本文中的github.com/attic-labs/testify/assert.True函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论