本文整理汇总了Golang中github.com/attic-labs/noms/types.NewString函数的典型用法代码示例。如果您正苦于以下问题:Golang NewString函数的具体用法?Golang NewString怎么用?Golang NewString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDataStoreDeleteConcurrent
func TestDataStoreDeleteConcurrent(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewMemoryStore()
ds := NewDataStore(cs)
datasetID := "ds1"
datasets := ds.Datasets()
assert.Zero(datasets.Len())
// |a|
a := types.NewString("a")
aCommit := NewCommit().SetValue(a)
ds, err := ds.Commit(datasetID, aCommit)
assert.NoError(err)
// |a| <- |b|
b := types.NewString("b")
bCommit := NewCommit().SetValue(b).SetParents(NewSetOfRefOfCommit().Insert(NewRefOfCommit(aCommit.Ref())))
ds2, err := ds.Commit(datasetID, bCommit)
assert.NoError(err)
assert.True(ds.Head(datasetID).Value().Equals(a))
assert.True(ds2.Head(datasetID).Value().Equals(b))
ds, err = ds.Delete(datasetID)
assert.NoError(err)
h, present := ds.MaybeHead(datasetID)
assert.False(present, "Dataset %s should not be present, but head is %v", datasetID, h.Value())
h, present = ds2.MaybeHead(datasetID)
assert.True(present, "Dataset %s should be present", datasetID)
// Get a fresh datastore, and verify that no datastores are present
newDs := NewDataStore(cs)
datasets = newDs.Datasets()
assert.Equal(uint64(0), datasets.Len())
}
开发者ID:arv,项目名称:noms-old,代码行数:35,代码来源:datastore_test.go
示例2: TestDataStoreDelete
func TestDataStoreDelete(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewMemoryStore()
ds := NewDataStore(cs)
datasetID1, datasetID2 := "ds1", "ds2"
datasets := ds.Datasets()
assert.Zero(datasets.Len())
// |a|
a := types.NewString("a")
ds, err := ds.Commit(datasetID1, NewCommit().SetValue(a))
assert.NoError(err)
assert.True(ds.Head(datasetID1).Value().Equals(a))
// ds1; |a|, ds2: |b|
b := types.NewString("b")
ds, err = ds.Commit(datasetID2, NewCommit().SetValue(b))
assert.NoError(err)
assert.True(ds.Head(datasetID2).Value().Equals(b))
ds, err = ds.Delete(datasetID1)
assert.NoError(err)
assert.True(ds.Head(datasetID2).Value().Equals(b))
h, present := ds.MaybeHead(datasetID1)
assert.False(present, "Dataset %s should not be present, but head is %v", datasetID1, h.Value())
// Get a fresh datastore, and verify that only ds1 is present
newDs := NewDataStore(cs)
datasets = newDs.Datasets()
assert.Equal(uint64(1), datasets.Len())
_, present = ds.MaybeHead(datasetID2)
assert.True(present, "Dataset %s should be present", datasetID2)
}
开发者ID:arv,项目名称:noms-old,代码行数:34,代码来源:datastore_test.go
示例3: 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
示例4: 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.NewString("a")
dsx, err := dsx.Commit(a)
assert.NoError(err)
assert.True(dsx.Head().Value().Equals(a))
// dsy: || -> |b|
_, ok := dsy.MaybeHead()
assert.False(ok)
b := types.NewString("b")
dsy, err = dsy.Commit(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.Commit(b)
assert.NoError(err)
assert.True(dsy.Head().Value().Equals(b))
}
开发者ID:arv,项目名称:noms-old,代码行数:26,代码来源:dataset_test.go
示例5: 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
示例6: readerForUser
func readerForUser(v types.Value) []types.Value {
values := []types.Value{}
s := v.(User)
values = append(values, types.NewString(s._Id))
values = append(values, types.NewString(s._Name))
values = append(values, s._Photos)
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:8,代码来源:facebook.noms.go
示例7: ChildValues
func (s Song) ChildValues() (ret []types.Value) {
ret = append(ret, types.NewString(s._Title))
ret = append(ret, types.NewString(s._Artist))
ret = append(ret, types.NewString(s._Album))
ret = append(ret, types.NewString(s._Year))
ret = append(ret, s._Mp3)
return
}
开发者ID:arv,项目名称:noms-old,代码行数:8,代码来源:types.noms.go
示例8: readerForAlbum
func readerForAlbum(v types.Value) []types.Value {
values := []types.Value{}
s := v.(Album)
values = append(values, types.NewString(s._Id))
values = append(values, types.NewString(s._Title))
values = append(values, s._Photos)
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:8,代码来源:types.noms.go
示例9: readerForSong
func readerForSong(v types.Value) []types.Value {
values := []types.Value{}
s := v.(Song)
values = append(values, types.NewString(s._Title))
values = append(values, types.NewString(s._Artist))
values = append(values, types.NewString(s._Album))
values = append(values, types.NewString(s._Year))
values = append(values, s._Mp3)
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:10,代码来源:types.noms.go
示例10: ChildValues
func (s RemotePhoto) ChildValues() (ret []types.Value) {
ret = append(ret, types.NewString(s._Id))
ret = append(ret, types.NewString(s._Title))
ret = append(ret, s._Date)
ret = append(ret, s._Geoposition)
ret = append(ret, s._Sizes)
ret = append(ret, s._Tags)
ret = append(ret, s._Faces)
return
}
开发者ID:arv,项目名称:noms-old,代码行数:10,代码来源:photo.noms.go
示例11: readerForRemotePhoto
func readerForRemotePhoto(v types.Value) []types.Value {
values := []types.Value{}
s := v.(RemotePhoto)
values = append(values, types.NewString(s._Id))
values = append(values, types.NewString(s._Title))
values = append(values, s._Date)
values = append(values, s._Geoposition)
values = append(values, s._Sizes)
values = append(values, s._Tags)
values = append(values, s._Faces)
return values
}
开发者ID:arv,项目名称:noms-old,代码行数:12,代码来源:photo.noms.go
示例12: New
func (def MapOfStringToRefOfCompanyDef) New() MapOfStringToRefOfCompany {
kv := make([]types.Value, 0, len(def)*2)
for k, v := range def {
kv = append(kv, types.NewString(k), NewRefOfCompany(v))
}
return MapOfStringToRefOfCompany{types.NewTypedMap(__typeForMapOfStringToRefOfCompany, kv...), &ref.Ref{}}
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:sha1_6c64b08.go
示例13: fromElemSlice
func (l ListOfString) fromElemSlice(p []string) []types.Value {
r := make([]types.Value, len(p))
for i, v := range p {
r[i] = types.NewString(v)
}
return r
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:ref.noms.go
示例14: New
func (def ListOfStringDef) New() ListOfString {
l := make([]types.Value, len(def))
for i, d := range def {
l[i] = types.NewString(d)
}
return ListOfString{types.NewTypedList(__typeForListOfString, l...), &ref.Ref{}}
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:ref.noms.go
示例15: TestCSVImporterWithPipe
func (s *testSuite) TestCSVImporterWithPipe() {
oldDelimiter := delimiter
newDelimiter := "|"
delimiter = &newDelimiter
defer func() { delimiter = oldDelimiter }()
input, err := ioutil.TempFile(s.TempDir, "")
d.Chk.NoError(err)
defer input.Close()
defer os.Remove(input.Name())
_, err = input.WriteString("a|b\n1|2\n")
d.Chk.NoError(err)
storeName := "store"
setName := "csv"
out := s.Run(main, []string{"-store", storeName, "-column-types", "String,Uint8", "-ds", setName, input.Name()})
s.Equal("", out)
cs := chunks.NewLevelDBStore(s.LdbDir, storeName, 1, false)
ds := dataset.NewDataset(datas.NewDataStore(cs), setName)
defer ds.Store().Close()
defer os.RemoveAll(s.LdbDir)
l := ds.Head().Value().(types.List)
s.Equal(uint64(1), l.Len())
v := l.Get(0)
st := v.(types.Struct)
s.Equal(types.NewString("1"), st.Get("a"))
s.Equal(types.Uint8(2), st.Get("b"))
}
开发者ID:arv,项目名称:noms-old,代码行数:31,代码来源:importer_test.go
示例16: New
func (def MapOfStringToValueDef) New() MapOfStringToValue {
kv := make([]types.Value, 0, len(def)*2)
for k, v := range def {
kv = append(kv, types.NewString(k), v)
}
return MapOfStringToValue{types.NewTypedMap(__typeForMapOfStringToValue, kv...), &ref.Ref{}}
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:map.noms.go
示例17: SetupTest
func (suite *WalkTestSuite) SetupTest() {
suite.vs = types.NewTestValueStore()
suite.shouldSeeItem = types.NewString("zzz")
suite.shouldSee = types.NewList(suite.shouldSeeItem)
suite.deadValue = types.Uint64(0xDEADBEEF)
suite.mustSkip = types.NewList(suite.deadValue)
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:walk_test.go
示例18: TestValueMapDef
func TestValueMapDef(t *testing.T) {
assert := assert.New(t)
def := gen.MapOfStringToValueDef{"s": types.NewString("s"), "i": types.Int32(42)}
m := def.New()
assert.Equal(uint64(2), m.Len())
assert.True(types.NewString("s").Equals(m.Get("s")))
assert.True(types.Int32(42).Equals(m.Get("i")))
def2 := m.Def()
assert.Equal(def, def2)
m2 := gen.NewMapOfStringToValue().Set("s", types.NewString("s")).Set("i", types.Int32(42))
assert.True(m.Equals(m2))
}
开发者ID:arv,项目名称:noms-old,代码行数:16,代码来源:map_test.go
示例19: NewKey
func NewKey() Key {
return Key{
__unionIndex: 0,
__unionValue: types.NewString(""),
ref: &ref.Ref{},
}
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:index.noms.go
示例20: New
func (def MapOfSizeToStringDef) New() MapOfSizeToString {
kv := make([]types.Value, 0, len(def)*2)
for k, v := range def {
kv = append(kv, k.New(), types.NewString(v))
}
return MapOfSizeToString{types.NewTypedMap(__typeForMapOfSizeToString, kv...), &ref.Ref{}}
}
开发者ID:arv,项目名称:noms-old,代码行数:7,代码来源:photo.noms.go
注:本文中的github.com/attic-labs/noms/types.NewString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论