本文整理汇总了Golang中github.com/attic-labs/testify/assert.True函数的典型用法代码示例。如果您正苦于以下问题:Golang True函数的具体用法?Golang True怎么用?Golang True使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了True函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
}
示例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))
}
示例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)
}
}
}
}
示例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)))
}
示例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))
}
示例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))
}
示例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)))
}
示例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
})
}
示例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{})
}
示例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()))
}
示例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()))
}
示例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))
}
示例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()))
}
示例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),
})))
}
示例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))
}