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


Golang dependency.Parse函數代碼示例

本文整理匯總了Golang中pault/ag/go/debian/dependency.Parse函數的典型用法代碼示例。如果您正苦於以下問題:Golang Parse函數的具體用法?Golang Parse怎麽用?Golang Parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Parse函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestResolverVersion

func TestResolverVersion(t *testing.T) {
	arch, err := dependency.ParseArch("amd64")
	isok(t, err)

	candidates, err := resolver.ReadFromBinaryIndex(
		strings.NewReader(testBinaryIndex),
	)
	isok(t, err)
	assert(t, len(*candidates) == 3)

	dep, err := dependency.Parse("android-tools-fsutils (>= 1.0)")
	isok(t, err)
	possi := dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == true)

	dep, err = dependency.Parse("android-tools-fsutils (>= 1:1.0)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == false)

	dep, err = dependency.Parse("android-tools-fsutils (<= 1:1.0)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == true)

	dep, err = dependency.Parse("android-tools-fsutils (<= 0:0)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == false)

	dep, err = dependency.Parse("android-tools-fsutils (= 4.2.2+git20130529-5.1)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == true)

	dep, err = dependency.Parse("android-tools-fsutils (= 2.2.2+git20130529-5.1)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == false)

	dep, err = dependency.Parse("android-tools-fsutils (<< 4.2.2+git20130529-5.1)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == false)

	dep, err = dependency.Parse("android-tools-fsutils (<< 4.2.2+git20130529-6.1)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == true)

	dep, err = dependency.Parse("android-tools-fsutils (>> 4.2.2+git20130529-5.1)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == false)

	dep, err = dependency.Parse("android-tools-fsutils (>> 4.2.2+git20130529-4.1)")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == true)
}
開發者ID:paultag,項目名稱:go-resolver,代碼行數:60,代碼來源:index_test.go

示例2: TestDoubleInvalidNotArch

func TestDoubleInvalidNotArch(t *testing.T) {
	_, err := dependency.Parse("foo [arch !foo]")
	notok(t, err)

	_, err = dependency.Parse("foo [arch!foo]")
	notok(t, err)
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:7,代碼來源:parser_test.go

示例3: TestMultiarchParse

func TestMultiarchParse(t *testing.T) {
	dep, err := dependency.Parse("foo:amd64")
	isok(t, err)

	assert(t, dep.Relations[0].Possibilities[0].Name == "foo")
	assert(t, dep.Relations[0].Possibilities[0].Arch.CPU == "amd64")

	dep, err = dependency.Parse("foo:amd64 [amd64 sparc]")
	isok(t, err)

	assert(t, dep.Relations[0].Possibilities[0].Name == "foo")
	assert(t, dep.Relations[0].Possibilities[0].Arch.CPU == "amd64")

	assert(t, dep.Relations[0].Possibilities[0].Architectures.Architectures[0].CPU == "amd64")
	assert(t, dep.Relations[0].Possibilities[0].Architectures.Architectures[1].CPU == "sparc")
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:16,代碼來源:parser_test.go

示例4: TestInsaneRoundTrip

func TestInsaneRoundTrip(t *testing.T) {
	dep, err := dependency.Parse("foo:armhf <stage1 !cross> [amd64 i386] (>= 1.2:3.4~5.6-7.8~9.0) <!stage1 cross>")
	isok(t, err)

	assert(t, dep.String() == "foo:armhf [amd64 i386] (>= 1.2:3.4~5.6-7.8~9.0) <stage1 !cross> <!stage1 cross>")

	rtDep, err := dependency.Parse(dep.String())
	isok(t, err)
	assert(t, dep.String() == rtDep.String())

	dep.Relations[0].Possibilities[0].Architectures.Not = true
	assert(t, dep.String() == "foo:armhf [!amd64 !i386] (>= 1.2:3.4~5.6-7.8~9.0) <stage1 !cross> <!stage1 cross>")

	rtDep, err = dependency.Parse(dep.String())
	isok(t, err)
	assert(t, dep.String() == rtDep.String())
}
開發者ID:Lightstreamer,項目名稱:official-images,代碼行數:17,代碼來源:parser_test.go

示例5: getOptionalDependencyField

func (para *Paragraph) getOptionalDependencyField(field string) dependency.Dependency {
	val := para.Values[field]
	dep, err := dependency.Parse(val)
	if err != nil {
		return dependency.Dependency{}
	}
	return *dep
}
開發者ID:Lightstreamer,項目名稱:official-images,代碼行數:8,代碼來源:control.go

示例6: TestSingleParse

func TestSingleParse(t *testing.T) {
	dep, err := dependency.Parse("foo")
	isok(t, err)

	if dep.Relations[0].Possibilities[0].Name != "foo" {
		t.Fail()
	}
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:8,代碼來源:parser_test.go

示例7: TestResolverDependsVersion

func TestResolverDependsVersion(t *testing.T) {
	candidates, err := resolver.ReadFromBinaryIndex(
		strings.NewReader(testBinaryIndex),
	)
	isok(t, err)
	assert(t, len(*candidates) == 3)

	arch, err := dependency.ParseArch("amd64")
	isok(t, err)

	dep, err := dependency.Parse("android-tools-fsutils (>= 1.0)")
	isok(t, err)
	assert(t, candidates.SatisfiesBuildDepends(*arch, *dep) == true)

	dep, err = dependency.Parse("android-tools-fsutils (>= 1.0), quix")
	isok(t, err)
	assert(t, candidates.SatisfiesBuildDepends(*arch, *dep) == false)
}
開發者ID:paultag,項目名稱:go-resolver,代碼行數:18,代碼來源:index_test.go

示例8: TestVersioning

func TestVersioning(t *testing.T) {
	dep, err := dependency.Parse("foo (>= 1.0)")
	isok(t, err)
	assert(t, len(dep.Relations) == 1)

	possi := dep.Relations[0].Possibilities[0]
	version := possi.Version

	assert(t, version.Operator == ">=")
	assert(t, version.Number == "1.0")
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:11,代碼來源:parser_test.go

示例9: TestResolverBasics

func TestResolverBasics(t *testing.T) {
	arch, err := dependency.ParseArch("amd64")
	isok(t, err)

	candidates, err := resolver.ReadFromBinaryIndex(
		strings.NewReader(testBinaryIndex),
	)
	isok(t, err)
	assert(t, len(*candidates) == 3)

	dep, err := dependency.Parse("baz")
	isok(t, err)
	possi := dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == false)

	dep, err = dependency.Parse("android-tools-fsutils")
	isok(t, err)
	possi = dep.GetAllPossibilities()[0]
	assert(t, candidates.Satisfies(*arch, possi) == true)
}
開發者ID:paultag,項目名稱:go-resolver,代碼行數:20,代碼來源:index_test.go

示例10: TestTwoPossibilities

func TestTwoPossibilities(t *testing.T) {
	dep, err := dependency.Parse("foo, bar | baz")
	isok(t, err)
	assert(t, len(dep.Relations) == 2)

	possi := dep.Relations[1].Possibilities
	assert(t, len(possi) == 2)

	assert(t, possi[0].Name == "bar")
	assert(t, possi[1].Name == "baz")
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:11,代碼來源:parser_test.go

示例11: TestSliceAllParse

func TestSliceAllParse(t *testing.T) {
	dep, err := dependency.Parse("foo, bar | baz")
	isok(t, err)

	els := dep.GetAllPossibilities()
	assert(t, len(els) == 3)

	assert(t, els[0].Name == "foo")
	assert(t, els[1].Name == "bar")
	assert(t, els[2].Name == "baz")
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:11,代碼來源:dependency_test.go

示例12: TestSingleArch

func TestSingleArch(t *testing.T) {
	dep, err := dependency.Parse("foo [arch]")
	isok(t, err)
	assert(t, len(dep.Relations) == 1)

	possi := dep.Relations[0].Possibilities[0]
	arches := possi.Architectures.Architectures

	assert(t, len(arches) == 1)
	assert(t, arches[0].CPU == "arch")
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:11,代碼來源:parser_test.go

示例13: TestArchSliceParse

func TestArchSliceParse(t *testing.T) {
	dep, err := dependency.Parse("foo, bar [sparc] | baz")
	isok(t, err)
	arch, err := dependency.ParseArch("amd64")
	isok(t, err)

	els := dep.GetPossibilities(*arch)
	assert(t, len(els) == 2)

	assert(t, els[0].Name == "foo")
	assert(t, els[1].Name == "baz")
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:12,代碼來源:dependency_test.go

示例14: TestSingleSubstvar

func TestSingleSubstvar(t *testing.T) {
	dep, err := dependency.Parse("${foo:Depends}, bar, baz")
	isok(t, err)
	assert(t, len(dep.Relations) == 3)

	assert(t, dep.Relations[0].Possibilities[0].Name == "foo:Depends")
	assert(t, dep.Relations[1].Possibilities[0].Name == "bar")
	assert(t, dep.Relations[2].Possibilities[0].Name == "baz")

	assert(t, dep.Relations[0].Possibilities[0].Substvar)

	assert(t, !dep.Relations[1].Possibilities[0].Substvar)
	assert(t, !dep.Relations[2].Possibilities[0].Substvar)
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:14,代碼來源:parser_test.go

示例15: TestBadArch

func TestBadArch(t *testing.T) {
	vers := []string{
		"foo [amd64",
		"foo [amd6",
		"foo [amd",
		"foo [am",
		"foo [a",
		"foo [",
	}

	for _, ver := range vers {
		_, err := dependency.Parse(ver)
		notok(t, err)
	}
}
開發者ID:stapelberg,項目名稱:go-debian,代碼行數:15,代碼來源:parser_test.go


注:本文中的pault/ag/go/debian/dependency.Parse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。