• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang rand.String函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/vmturbo/vmturbo-go-sdk/util/rand.String函数的典型用法代码示例。如果您正苦于以下问题:Golang String函数的具体用法?Golang String怎么用?Golang String使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了String函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestBuys_False

// Tests that a CommodityDTO is created with the arguments commodityType, key and used arguments
// as its members . Tests that the created CommodityDTO is added to the Bought array in the
// existing EntityDTO_CommodityBought struct with *ProviderId = * eb.currentProvider.Id
// When find = false
func TestBuys_False(t *testing.T) {
	assert := assert.New(t)
	entity := new(EntityDTO)
	providerIdStr := rand.String(5)
	entityDTOBuilder := &EntityDTOBuilder{
		entity: entity,
	}
	providerDTO := new(ProviderDTO)
	providerDTO.Id = &providerIdStr
	entityDTOBuilder.currentProvider = providerDTO
	commType := new(CommodityDTO_CommodityType)
	key := rand.String(6)
	r := mathrand.New(mathrand.NewSource(99))
	used := r.Float64()
	assert.Equal(0, len(entityDTOBuilder.entity.CommoditiesBought))
	eb := entityDTOBuilder.Buys(*commType, key, used)
	// eb.GetCommoditiesBought  => eb.CommoditiesBought  type []*EntityDTO_CommodityBought
	assert.Equal(1, len(eb.entity.CommoditiesBought))
	assert.Equal(commType, eb.entity.CommoditiesBought[0].Bought[0].CommodityType)
	assert.Equal(*commType, *eb.entity.CommoditiesBought[0].Bought[0].CommodityType)
	assert.Equal(&key, eb.entity.CommoditiesBought[0].Bought[0].Key)
	assert.Equal(key, *eb.entity.CommoditiesBought[0].Bought[0].Key)
	assert.Equal(&used, eb.entity.CommoditiesBought[0].Bought[0].Used)
	assert.Equal(used, *eb.entity.CommoditiesBought[0].Bought[0].Used)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:29,代码来源:entity_dto_builder_test.go


示例2: TestNewProbeInfoBuilder

// Tests that NewProbeInfoBuilder creates a ProbeInfo struct with member variables set to the
// arguments passed to it and creates a ProbeInfoBuilder struct with its probeInfo variable set
// to the new ProbeInfo struct containing the passed arguments
func TestNewProbeInfoBuilder(t *testing.T) {
	assert := assert.New(t)
	probeType := rand.String(6)
	probeCat := rand.String(7)
	var supplyCS []*sdk.TemplateDTO
	var acctDef []*AccountDefEntry
	probeInfoBldr := NewProbeInfoBuilder(probeType, probeCat, supplyCS, acctDef)
	assert.Equal(probeType, *probeInfoBldr.probeInfo.ProbeType)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:12,代码来源:builder_test.go


示例3: TestSetProperty_notnil

// Tests that the name and value passed as arguments to SetProperty are
// appended to the array EntityProperties of eb.entity
// Test case when eb.entity.GetEntityProperties != nil
func TestSetProperty_notnil(t *testing.T) {
	assert := assert.New(t)
	entity := new(EntityDTO)
	name := rand.String(5)
	value := rand.String(6)
	entityDTOBuilder := &EntityDTOBuilder{
		entity: entity,
	}
	eb := entityDTOBuilder.SetProperty(name, value)
	assert.Equal(&name, eb.entity.EntityProperties[0].Name)
	assert.Equal(name, *eb.entity.EntityProperties[0].Name)
	assert.Equal(&value, eb.entity.EntityProperties[0].Value)
	assert.Equal(value, *eb.entity.EntityProperties[0].Value)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:17,代码来源:entity_dto_builder_test.go


示例4: TestFindCommBoughtProvider_False_inrange

// Test to assert that the correct *EntityDTO_CommodityBought is returned if the
// providerId for this struct is the same as the providerId passed to the method findCommBoughtProvider
func TestFindCommBoughtProvider_False_inrange(t *testing.T) {
	assert := assert.New(t)
	entity := new(EntityDTO)
	providerIdStr := rand.String(5)
	currentProviderIdStr := rand.String(6)
	entityDTO_CommodityBought := new(EntityDTO_CommodityBought)
	entityDTO_CommodityBought.ProviderId = &providerIdStr
	// Bought array is len = 0 for this EntityDTO_CommodityBought
	entity.CommoditiesBought = append(entity.CommoditiesBought, entityDTO_CommodityBought)
	entityDTOBuilder := &EntityDTOBuilder{
		entity: entity,
	}
	commBoughtProvider, wasFound := entityDTOBuilder.findCommBoughtProvider(&currentProviderIdStr)
	assert.Equal(false, wasFound)
	assert.Equal((*EntityDTO_CommodityBought)(nil), commBoughtProvider)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:18,代码来源:entity_dto_builder_test.go


示例5: TestProbeEntityPropertyDef

// Tests that the name and description string arguments passed to ProbeEntityPropertyDef() are
// used to set the Name and Description member variables of a newly created ExternalEntityLink_EntityPropertyDef
// struct .
// Tests that the created struct is appended to this.entityLink.ProbeEntityPropertyDef array
func TestProbeEntityPropertyDef(t *testing.T) {
	assert := assert.New(t)
	externalEntityLink := new(ExternalEntityLink)
	externalEntityLinkBuilder := &ExternalEntityLinkBuilder{
		entityLink: externalEntityLink,
	}
	name := rand.String(6)
	description := rand.String(6)
	assert.Equal(0, len(externalEntityLink.ProbeEntityPropertyDef))
	eelb := externalEntityLinkBuilder.ProbeEntityPropertyDef(name, description)
	if assert.Equal(1, len(externalEntityLink.ProbeEntityPropertyDef)) {
		assert.Equal(&name, eelb.entityLink.ProbeEntityPropertyDef[0].Name)
		assert.Equal(name, *eelb.entityLink.ProbeEntityPropertyDef[0].Name)
		assert.Equal(&description, eelb.entityLink.ProbeEntityPropertyDef[0].Description)
		assert.Equal(description, *eelb.entityLink.ProbeEntityPropertyDef[0].Description)
	}
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:21,代码来源:external_link_builder_test.go


示例6: TestSetProperty_nil

// Tests that the name and value passed as arguments to SetProperty are
// appended to the array EntityProperties of eb.entity
// Test case when eb.entity.GetEntityProperties = nil
func TestSetProperty_nil(t *testing.T) {
	assert := assert.New(t)
	entity := new(EntityDTO)
	name := rand.String(5)
	value := rand.String(6)
	entity.EntityProperties = nil
	entityDTOBuilder := &EntityDTOBuilder{
		entity: entity,
	}
	assert.Equal([]*EntityDTO_EntityProperty(nil), entityDTOBuilder.entity.EntityProperties)
	//assert.Equal(([]*EntityDTO_EntityProperty)(nil), entityDTOBuilder.entity.EntityProperties)
	//	assert.Nil(t, entityDTOBuilder.entity.EntityProperties)
	eb := entityDTOBuilder.SetProperty(name, value)
	assert.Equal(&name, eb.entity.EntityProperties[0].Name)
	assert.Equal(name, *eb.entity.EntityProperties[0].Name)
	assert.Equal(&value, eb.entity.EntityProperties[0].Value)
	assert.Equal(value, *eb.entity.EntityProperties[0].Value)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:21,代码来源:entity_dto_builder_test.go


示例7: TestGetId

// Tests that the getId() method returns a string pointer to
// the Id member variable of the ProviderDTO struct that getId() is called on
func TestGetId(t *testing.T) {
	assert := assert.New(t)
	fmt.Println("in TestProviderDTOProviderID")
	id := rand.String(5)
	providerDto := &ProviderDTO{
		Id: &id,
	}
	assert.Equal(&id, providerDto.getId())
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:11,代码来源:entity_dto_builder_test.go


示例8: TestNewAccountDefEntryBuilder

// Tests that the method NewAccountDefEntryBuilder creates an AccountDefEntry struct with member
// variables set equal to the pointers to the arguments passed to it
func TestNewAccountDefEntryBuilder(t *testing.T) {
	assert := assert.New(t)
	name := rand.String(6)
	displayName := rand.String(7)
	description := rand.String(8)
	verificationRegex := rand.String(9)
	entryType := AccountDefEntry_OPTIONAL
	isSecret := true
	acctDefEntryBuilder := NewAccountDefEntryBuilder(name, displayName, description, verificationRegex, entryType, isSecret)
	acctDef := acctDefEntryBuilder.accountDefEntry
	if assert.NotEqual((*AccountDefEntry)(nil), acctDef) {
		assert.Equal(name, *acctDef.Name)
		assert.Equal(displayName, *acctDef.DisplayName)
		assert.Equal(description, *acctDef.Description)
		assert.Equal(verificationRegex, *acctDef.VerificationRegex)
		assert.Equal(entryType, *acctDef.Type)
		assert.Equal(isSecret, *acctDef.IsSecret)
	}
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:21,代码来源:builder_test.go


示例9: TestSetProvider

// test that the SetProvider method creates a ProviderDTO and sets its providerType and id to the
// passed arguments
func TestSetProvider(t *testing.T) {
	assert := assert.New(t)
	entityDTOBuilder := &EntityDTOBuilder{}
	pType := new(EntityDTO_EntityType)
	id := rand.String(6)
	eb := entityDTOBuilder.SetProvider(*pType, id)
	assert.Equal(pType, eb.currentProvider.providerType)
	assert.Equal(*pType, *eb.currentProvider.providerType)
	assert.Equal(&id, eb.currentProvider.Id)
	assert.Equal(id, *eb.currentProvider.Id)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:13,代码来源:entity_dto_builder_test.go


示例10: TestMatching

// Tests that the string passed to Matching() method is appended to the string array
// variable called IdentifyProp in this.metaData
func TestMatching(t *testing.T) {
	assert := assert.New(t)
	replacementEntityMD := new(EntityDTO_ReplacementEntityMetaData)
	replacementEMB := &ReplacementEntityMetaDataBuilder{
		metaData: replacementEntityMD,
	}
	propStr := rand.String(6)
	rEMB := replacementEMB.Matching(propStr)
	assert.Equal(propStr, rEMB.metaData.IdentifyingProp[0])
	assert.Equal(&propStr, &rEMB.metaData.IdentifyingProp[0])
}
开发者ID:enlinxu,项目名称:vmturbo-go-sdk,代码行数:13,代码来源:replacement_entity_meta_data_builder_test.go


示例11: TestDisplayName

// Tests method DisplayName() which sets the DisplayName of the entity member of the
// EntityDTOBuilder that calls DisplayName()
func TestDisplayName(t *testing.T) {
	assert := assert.New(t)
	entity := new(EntityDTO)
	entityDTOBuilder := &EntityDTOBuilder{
		entity: entity,
	}

	dispName := rand.String(6)
	entityDTOBuilder.DisplayName(dispName)
	assert.Equal(&dispName, entityDTOBuilder.entity.DisplayName)
	assert.Equal(dispName, *entityDTOBuilder.entity.DisplayName)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:14,代码来源:entity_dto_builder_test.go


示例12: TestNewEntityDTOBuilder

//Tests the method NewEntityDTOBuilder() , which should return a pointer to a EntityDTOBuilder
//instance containing only its EntityDTOBuilder.entity member instantiated.
func TestNewEntityDTOBuilder(t *testing.T) {
	assert := assert.New(t)
	pType := new(EntityDTO_EntityType)
	idstr := rand.String(5)
	entityDTOBuilder := NewEntityDTOBuilder(*pType, idstr)
	if assert.NotNil(t, entityDTOBuilder.entity) {
		assert.Equal(pType, entityDTOBuilder.entity.EntityType)
		assert.Equal(&idstr, entityDTOBuilder.entity.Id)
		if assert.NotNil(t, entityDTOBuilder.entity.CommoditiesBought) {
			assert.Equal(0, len(entityDTOBuilder.entity.CommoditiesBought))
		}
		if assert.NotNil(t, entityDTOBuilder.entity.CommoditiesSold) {
			assert.Equal(0, len(entityDTOBuilder.entity.CommoditiesSold))
		}
	}
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:18,代码来源:entity_dto_builder_test.go


示例13: TestSells

// Tests Sells() method which sets the CommodityType and key members of a new CommodityDTO instance
// and appends the new CommodityDTO instance to the CommoditiesSold member array of the entity memb// er of the EntityDTOBuilder that calls this method.
func TestSells(t *testing.T) {
	assert := assert.New(t)
	commType := new(CommodityDTO_CommodityType)
	keystr := rand.String(6)

	entity := new(EntityDTO)
	entityDTOBuilder := &EntityDTOBuilder{
		entity: entity,
	}

	if assert.NotNil(t, entityDTOBuilder.entity.CommoditiesSold) {
		assert.Equal(0, len(entityDTOBuilder.entity.CommoditiesSold))
	}
	entityDTOBuilder.Sells(*commType, keystr)
	assert.Equal(1, len(entityDTOBuilder.entity.CommoditiesSold))
	assert.Equal(commType, entityDTOBuilder.entity.CommoditiesSold[0].CommodityType)
	assert.Equal(*commType, *entityDTOBuilder.entity.CommoditiesSold[0].CommodityType)
	assert.Equal(keystr, *entityDTOBuilder.entity.CommoditiesSold[0].Key)
	assert.Equal(&keystr, entityDTOBuilder.entity.CommoditiesSold[0].Key)
}
开发者ID:DongyiYang,项目名称:vmturbo-go-sdk,代码行数:22,代码来源:entity_dto_builder_test.go



注:本文中的github.com/vmturbo/vmturbo-go-sdk/util/rand.String函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang govcloudair.NewClient函数代码示例发布时间:2022-05-28
下一篇:
Golang ldapserver.ResponseWriter类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap