本文整理汇总了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)
}
示例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)
}
示例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")
}
示例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())
}
示例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
}
示例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()
}
}
示例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)
}
示例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")
}
示例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)
}
示例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")
}
示例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")
}
示例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")
}
示例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")
}
示例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)
}
示例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)
}
}