當前位置: 首頁>>代碼示例>>Golang>>正文


Golang rand.String函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。