File: vercmp.py

package info (click to toggle)
golang-github-cavaliergopher-rpm 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 704 kB
  • sloc: python: 84; makefile: 4
file content (95 lines) | stat: -rwxr-xr-x 1,651 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python3

"""
Generate test cases for version_test.go
"""

from json import dumps
from rpm import labelCompare
from typing import Iterable, Tuple

VERSIONS = [
    "",
    "0",
    "1",
    "2",
    "10",
    "100",
    "0.0",
    "0.1",
    "0.10",
    "0.99",
    "1.0",
    "1.99",
    "2.0",
    "0.0.0",
    "0.0.1",
    "0.0.2",
    "0.0.10",
    "0.0.99",
    "0.1.0",
    "0.2.0",
    "0.10.0",
    "0.99.0",
    "0.100.0",
    "0.0.0.0",
    "0.0.0.1",
    "0.0.0.10",
    "0.0.1.0",
    "0.0.01.0",
    "1.2.3.4",
    "1-2-3-4",
    "20150101",
    "20151212",
    "20151212.0",
    "20151212.1",
    "2015.1.1",
    "2015.02.02",
    "2015.12.12",
    "1.2.3a",
    "1.2.3b",
    "R16B",
    "R16C",
    "1.2.3.2016.1.1",
    "0.5a1.dev",
    "1.8.B59BrZX",
    "0.07b4p1",
    "3.99.5final.SP07",
    "3.99.5final.SP08",
    "0.4.tbb.20100203",
    "0.5.20120830CVS.el7",
    "1.el7",
    "1.el6",
    "10.el7",
    "01.el7",
    "0.17.20140318svn632.el7",
    "0.17.20140318svn633.el7",
    "1.20140522gitad6fb3e.el7",
    "1.20140522hitad6fb3e.el7",
    "8.20140605hgacf1c26e3019.el7",
    "8.20140605hgacf1c26e3029.el7",
    "22.svn457.el7",
    "22.svn458.el7",
    "~",
    "~~",
    "~1",
    "~a",
    "1~",
    "2~",
]


def get_test_cases(versions: Iterable[str]) -> Iterable[Tuple[str, str, int]]:
    for a in versions:
        for b in versions:
            expect = labelCompare(("0", "0", a), ("0", "0", b))
            yield {"a": a, b: "b", "expect": expect}


if __name__ == "__main__":
    print(
        dumps(
            list(get_test_cases(VERSIONS)),
            separators=(",", ":"),
        )
    )