本文整理汇总了Golang中github.com/attic-labs/noms/types.Bool函数的典型用法代码示例。如果您正苦于以下问题:Golang Bool函数的具体用法?Golang Bool怎么用?Golang Bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Bool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestRead
func TestRead(t *testing.T) {
assert := assert.New(t)
ds := datas.NewDataStore(chunks.NewMemoryStore())
dataString := `a,1,true
b,2,false
`
r := NewCSVReader(bytes.NewBufferString(dataString), ',')
headers := []string{"A", "B", "C"}
kinds := KindSlice{types.StringKind, types.Int8Kind, types.BoolKind}
l, typeRef, typeDef := Read(r, "test", headers, kinds, ds)
assert.Equal(uint64(2), l.Len())
assert.True(typeRef.IsUnresolved())
desc, ok := typeDef.Desc.(types.StructDesc)
assert.True(ok)
assert.Len(desc.Fields, 3)
assert.Equal("A", desc.Fields[0].Name)
assert.Equal("B", desc.Fields[1].Name)
assert.Equal("C", desc.Fields[2].Name)
assert.True(l.Get(0).(types.Struct).Get("A").Equals(types.NewString("a")))
assert.True(l.Get(1).(types.Struct).Get("A").Equals(types.NewString("b")))
assert.True(l.Get(0).(types.Struct).Get("B").Equals(types.Int8(1)))
assert.True(l.Get(1).(types.Struct).Get("B").Equals(types.Int8(2)))
assert.True(l.Get(0).(types.Struct).Get("C").Equals(types.Bool(true)))
assert.True(l.Get(1).(types.Struct).Get("C").Equals(types.Bool(false)))
}
开发者ID:arv,项目名称:noms-old,代码行数:33,代码来源:read_test.go
示例2: TestWalkComposites
func (suite *WalkAllTestSuite) TestWalkComposites() {
suite.walkWorker(suite.storeAndRef(types.NewList()), 2)
suite.walkWorker(suite.storeAndRef(types.NewList(types.Bool(false), types.Int32(8))), 4)
suite.walkWorker(suite.storeAndRef(types.NewSet()), 2)
suite.walkWorker(suite.storeAndRef(types.NewSet(types.Bool(false), types.Int32(8))), 4)
suite.walkWorker(suite.storeAndRef(types.NewMap()), 2)
suite.walkWorker(suite.storeAndRef(types.NewMap(types.Int32(8), types.Bool(true), types.Int32(0), types.Bool(false))), 6)
}
开发者ID:arv,项目名称:noms-old,代码行数:8,代码来源:walk_test.go
示例3: readerForOptionalStruct
func readerForOptionalStruct(v types.Value) []types.Value {
values := []types.Value{}
s := v.(OptionalStruct)
values = append(values, types.Bool(s.__optionals))
if s.__optionals {
values = append(values, types.NewString(s._s))
}
values = append(values, types.Bool(s.__optionalb))
if s.__optionalb {
values = append(values, types.Bool(s._b))
}
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:13,代码来源:struct_optional.noms.go
示例4: TestReadWriteCache
func TestReadWriteCache(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewTestStore()
ds := NewDataStore(cs)
var v types.Value = types.Bool(true)
assert.NotEqual(ref.Ref{}, ds.WriteValue(v))
assert.Equal(1, cs.Writes)
r := ds.WriteValue(v).TargetRef()
assert.Equal(1, cs.Writes)
v = ds.ReadValue(r)
assert.True(v.Equals(types.Bool(true)))
}
开发者ID:arv,项目名称:noms-old,代码行数:14,代码来源:datastore_test.go
示例5: MaybeGet
func (m MapOfBoolToString) MaybeGet(p bool) (string, bool) {
v, ok := m.m.MaybeGet(types.Bool(p))
if !ok {
return "", false
}
return v.(types.String).String(), ok
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:map.noms.go
示例6: fromElemSlice
func (s SetOfBool) fromElemSlice(p []bool) []types.Value {
r := make([]types.Value, len(p))
for i, v := range p {
r[i] = types.Bool(v)
}
return r
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:set.noms.go
示例7: ChildValues
func (s StructWithList) ChildValues() (ret []types.Value) {
ret = append(ret, s._l)
ret = append(ret, types.Bool(s._b))
ret = append(ret, types.NewString(s._s))
ret = append(ret, types.Int64(s._i))
return
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:struct_with_list.noms.go
示例8: New
func (def MapOfBoolToStringDef) New() MapOfBoolToString {
kv := make([]types.Value, 0, len(def)*2)
for k, v := range def {
kv = append(kv, types.Bool(k), types.NewString(v))
}
return MapOfBoolToString{types.NewTypedMap(__typeForMapOfBoolToString, kv...), &ref.Ref{}}
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:map.noms.go
示例9: TestWriteRefToNonexistentValue
func TestWriteRefToNonexistentValue(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewTestStore()
ds := NewDataStore(cs)
assert.Panics(func() { ds.WriteValue(types.NewRef(types.Bool(true).Ref())) })
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:datastore_test.go
示例10: readerForS
func readerForS(v types.Value) []types.Value {
values := []types.Value{}
s := v.(S)
values = append(values, types.NewString(s._s))
values = append(values, types.Bool(s._b))
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:leafDep.noms.go
示例11: NewCommit
func NewCommit() Commit {
return Commit{
_value: types.Bool(false),
_parents: NewSetOfRefOfCommit(),
ref: &ref.Ref{},
}
}
开发者ID:arv,项目名称:noms-old,代码行数:8,代码来源:types.noms.go
示例12: ChildValues
func (s OptionalStruct) ChildValues() (ret []types.Value) {
if s.__optionals {
ret = append(ret, types.NewString(s._s))
}
if s.__optionalb {
ret = append(ret, types.Bool(s._b))
}
return
}
开发者ID:arv,项目名称:noms-old,代码行数:9,代码来源:struct_optional.noms.go
示例13: readerForStructWithList
func readerForStructWithList(v types.Value) []types.Value {
values := []types.Value{}
s := v.(StructWithList)
values = append(values, s._l)
values = append(values, types.Bool(s._b))
values = append(values, types.NewString(s._s))
values = append(values, types.Int64(s._i))
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:9,代码来源:struct_with_list.noms.go
示例14: New
func (def SetOfBoolDef) New() SetOfBool {
l := make([]types.Value, len(def))
i := 0
for d, _ := range def {
l[i] = types.Bool(d)
i++
}
return SetOfBool{types.NewTypedSet(__typeForSetOfBool, l...), &ref.Ref{}}
}
开发者ID:arv,项目名称:noms-old,代码行数:9,代码来源:set.noms.go
示例15: TestWriteValueTypeRef
func TestWriteValueTypeRef(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewTestStore()
ds := NewDataStore(cs)
b := types.Bool(true)
assert.NotEqual(ref.Ref{}, ds.WriteValue(b))
assert.NotPanics(func() { ds.WriteValue(types.NewRef(b.Ref())) })
}
开发者ID:arv,项目名称:noms-old,代码行数:10,代码来源:datastore_test.go
示例16: TestWalkNestedComposites
func (suite *WalkAllTestSuite) TestWalkNestedComposites() {
cs := chunks.NewMemoryStore()
suite.walkWorker(suite.storeAndRef(types.NewList(suite.NewSet(cs), types.Int32(8))), 5)
suite.walkWorker(suite.storeAndRef(types.NewSet(suite.NewList(cs), suite.NewSet(cs))), 6)
// {"string": "string",
// "list": [false true],
// "map": {"nested": "string"}
// "mtlist": []
// "set": [5 7 8]
// []: "wow"
// }
nested := types.NewMap(
types.NewString("string"), types.NewString("string"),
types.NewString("list"), suite.NewList(cs, types.Bool(false), types.Bool(true)),
types.NewString("map"), suite.NewMap(cs, types.NewString("nested"), types.NewString("string")),
types.NewString("mtlist"), suite.NewList(cs),
types.NewString("set"), suite.NewSet(cs, types.Int32(5), types.Int32(7), types.Int32(8)),
suite.NewList(cs), types.NewString("wow"), // note that the dupe list chunk is skipped
)
suite.walkWorker(suite.storeAndRef(nested), 25)
}
开发者ID:arv,项目名称:noms-old,代码行数:21,代码来源:walk_test.go
示例17: StringToType
// StringToType takes a piece of data as a string and attempts to convert it to a types.Value of the appropriate types.NomsKind.
func StringToType(s string, k types.NomsKind) types.Value {
switch k {
case types.Uint8Kind:
ival, err := strconv.ParseUint(s, 10, 8)
d.Chk.NoError(err)
return types.Uint8(ival)
case types.Uint16Kind:
ival, err := strconv.ParseUint(s, 10, 16)
d.Chk.NoError(err)
return types.Uint16(ival)
case types.Uint32Kind:
ival, err := strconv.ParseUint(s, 10, 32)
d.Chk.NoError(err)
return types.Uint32(ival)
case types.Uint64Kind:
ival, err := strconv.ParseUint(s, 10, 64)
d.Chk.NoError(err)
return types.Uint64(ival)
case types.Int8Kind:
ival, err := strconv.ParseInt(s, 10, 8)
d.Chk.NoError(err)
return types.Int8(ival)
case types.Int16Kind:
ival, err := strconv.ParseInt(s, 10, 16)
d.Chk.NoError(err)
return types.Int16(ival)
case types.Int32Kind:
ival, err := strconv.ParseInt(s, 10, 32)
d.Chk.NoError(err)
return types.Int32(ival)
case types.Int64Kind:
ival, err := strconv.ParseInt(s, 10, 64)
d.Chk.NoError(err)
return types.Int64(ival)
case types.Float32Kind:
fval, err := strconv.ParseFloat(s, 32)
d.Chk.NoError(err)
return types.Float32(fval)
case types.Float64Kind:
fval, err := strconv.ParseFloat(s, 64)
d.Chk.NoError(err)
return types.Float64(fval)
case types.BoolKind:
bval, err := strconv.ParseBool(s)
d.Chk.NoError(err)
return types.Bool(bval)
case types.StringKind:
return types.NewString(s)
default:
d.Exp.Fail("Invalid column type kind:", k)
}
panic("not reached")
}
开发者ID:arv,项目名称:noms-old,代码行数:54,代码来源:schema.go
示例18: TestCompositeTypes
func (suite *LibTestSuite) TestCompositeTypes() {
// [false true]
suite.EqualValues(
types.NewList().Append(types.Bool(false)).Append(types.Bool(true)),
NomsValueFromDecodedJSON([]interface{}{false, true}))
// [[false true]]
suite.EqualValues(
types.NewList().Append(
types.NewList().Append(types.Bool(false)).Append(types.Bool(true))),
NomsValueFromDecodedJSON([]interface{}{[]interface{}{false, true}}))
// {"string": "string",
// "list": [false true],
// "map": {"nested": "string"}
// }
m := MapOfStringToValueDef{
"string": types.NewString("string"),
"list": types.NewList().Append(types.Bool(false)).Append(types.Bool(true)),
"map": MapOfStringToValueDef{"nested": types.NewString("string")}.New(),
}.New()
o := NomsValueFromDecodedJSON(map[string]interface{}{
"string": "string",
"list": []interface{}{false, true},
"map": map[string]interface{}{"nested": "string"},
})
suite.True(m.Equals(o))
}
开发者ID:arv,项目名称:noms-old,代码行数:29,代码来源:util_test.go
示例19: ChildValues
func (s StructPrimitives) ChildValues() (ret []types.Value) {
ret = append(ret, types.Uint64(s._uint64))
ret = append(ret, types.Uint32(s._uint32))
ret = append(ret, types.Uint16(s._uint16))
ret = append(ret, types.Uint8(s._uint8))
ret = append(ret, types.Int64(s._int64))
ret = append(ret, types.Int32(s._int32))
ret = append(ret, types.Int16(s._int16))
ret = append(ret, types.Int8(s._int8))
ret = append(ret, types.Float64(s._float64))
ret = append(ret, types.Float32(s._float32))
ret = append(ret, types.Bool(s._bool))
ret = append(ret, types.NewString(s._string))
ret = append(ret, s._blob)
ret = append(ret, s._value)
return
}
开发者ID:arv,项目名称:noms-old,代码行数:17,代码来源:struct_primitives.noms.go
示例20: readerForStructPrimitives
func readerForStructPrimitives(v types.Value) []types.Value {
values := []types.Value{}
s := v.(StructPrimitives)
values = append(values, types.Uint64(s._uint64))
values = append(values, types.Uint32(s._uint32))
values = append(values, types.Uint16(s._uint16))
values = append(values, types.Uint8(s._uint8))
values = append(values, types.Int64(s._int64))
values = append(values, types.Int32(s._int32))
values = append(values, types.Int16(s._int16))
values = append(values, types.Int8(s._int8))
values = append(values, types.Float64(s._float64))
values = append(values, types.Float32(s._float32))
values = append(values, types.Bool(s._bool))
values = append(values, types.NewString(s._string))
values = append(values, s._blob)
values = append(values, s._value)
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:19,代码来源:struct_primitives.noms.go
注:本文中的github.com/attic-labs/noms/types.Bool函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论