Skip to content

Commit 7c1fa05

Browse files
committed
Test: add util to test deb version package comparison
1 parent dd18350 commit 7c1fa05

File tree

1 file changed

+214
-0
lines changed

1 file changed

+214
-0
lines changed
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
-- source: https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/scripts/t/Dpkg_Version.t
2+
DO
3+
$$
4+
declare
5+
result NUMERIC := 0;
6+
begin
7+
select * into result from rpm.rpmstrcmp('1.0-1', '2.0-2');
8+
if result <> -1
9+
then
10+
raise notice 'rpm.rpmstrcmp(1.0-1, 2.0-2) should be -1';
11+
end if;
12+
select * into result from rpm.rpmstrcmp('2.2~rc-4', '2.2-1');
13+
if result <> -1
14+
then
15+
raise notice 'rpm.rpmstrcmp(2.2~rc-4, 2.2-1) should be -1';
16+
end if;
17+
select * into result from rpm.rpmstrcmp('2.2-1', '2.2~rc-4');
18+
if result <> 1
19+
then
20+
raise notice 'rpm.rpmstrcmp(2.2-1, 2.2~rc-4) should be 1';
21+
end if;
22+
select * into result from rpm.rpmstrcmp('1.0000-1', '1.0-1');
23+
if result <> 0
24+
then
25+
raise notice 'rpm.rpmstrcmp(1.0000-1, 1.0-1) should be 0';
26+
end if;
27+
select * into result from rpm.rpmstrcmp('1', '1');
28+
if result <> 0
29+
then
30+
raise notice 'rpm.rpmstrcmp(1, 1) should be 0';
31+
end if;
32+
select * into result from rpm.rpmstrcmp('0', '0-0');
33+
if result <> 0
34+
then
35+
raise notice 'rpm.rpmstrcmp(0, 0-0) should be 0';
36+
end if;
37+
select * into result from rpm.rpmstrcmp('2.5', '7.5');
38+
if result <> -1
39+
then
40+
raise notice 'rpm.rpmstrcmp(2.5, 7.5) should be -1';
41+
end if;
42+
select * into result from rpm.rpmstrcmp('0foo', '0foo');
43+
if result <> 0
44+
then
45+
raise notice 'rpm.rpmstrcmp(0foo, 0foo) should be 0';
46+
end if;
47+
select * into result from rpm.rpmstrcmp('0foo-0', '0foo');
48+
if result <> 0
49+
then
50+
raise notice 'rpm.rpmstrcmp(0foo-0, 0foo) should be 0';
51+
end if;
52+
select * into result from rpm.rpmstrcmp('0foo', '0foo-0');
53+
if result <> 0
54+
then
55+
raise notice 'rpm.rpmstrcmp(0foo, 0foo-0) should be 0';
56+
end if;
57+
select * into result from rpm.rpmstrcmp('0foo', '0fo');
58+
if result <> 1
59+
then
60+
raise notice 'rpm.rpmstrcmp(0foo, 0fo) should be 1';
61+
end if;
62+
select * into result from rpm.rpmstrcmp('0foo-0', '0foo+');
63+
if result <> -1
64+
then
65+
raise notice 'rpm.rpmstrcmp(0foo-0, 0foo+) should be -1';
66+
end if;
67+
select * into result from rpm.rpmstrcmp('0foo~1', '0foo');
68+
if result <> -1
69+
then
70+
raise notice 'rpm.rpmstrcmp(0foo~1, 0foo) should be -1';
71+
end if;
72+
select * into result from rpm.rpmstrcmp('0foo~foo+Bar', '0foo~foo+bar');
73+
if result <> -1
74+
then
75+
raise notice 'rpm.rpmstrcmp(0foo~foo+Bar, 0foo~foo+bar) should be -1';
76+
end if;
77+
select * into result from rpm.rpmstrcmp('0foo~~', '0foo~');
78+
if result <> -1
79+
then
80+
raise notice 'rpm.rpmstrcmp(0foo~~, 0foo~) should be -1';
81+
end if;
82+
select * into result from rpm.rpmstrcmp('1~', '1');
83+
if result <> -1
84+
then
85+
raise notice 'rpm.rpmstrcmp(1~, 1) should be -1';
86+
end if;
87+
select * into result from rpm.rpmstrcmp('12345+that-really-is-some-ver-0', '12345+that-really-is-some-ver-10');
88+
if result <> -1
89+
then
90+
raise notice 'rpm.rpmstrcmp(12345+that-really-is-some-ver-0, 12345+that-really-is-some-ver-10) should be -1';
91+
end if;
92+
select * into result from rpm.rpmstrcmp('0foo-0', '0foo-01');
93+
if result <> -1
94+
then
95+
raise notice 'rpm.rpmstrcmp(0foo-0, 0foo-01) should be -1';
96+
end if;
97+
select * into result from rpm.rpmstrcmp('0foo.bar', '0foobar');
98+
if result <> 1
99+
then
100+
raise notice 'rpm.rpmstrcmp(0foo.bar, 0foobar) should be 1';
101+
end if;
102+
select * into result from rpm.rpmstrcmp('0foo.bar', '0foo1bar');
103+
if result <> 1
104+
then
105+
raise notice 'rpm.rpmstrcmp(0foo.bar, 0foo1bar) should be 1';
106+
end if;
107+
select * into result from rpm.rpmstrcmp('0foo.bar', '0foo0bar');
108+
if result <> 1
109+
then
110+
raise notice 'rpm.rpmstrcmp(0foo.bar, 0foo0bar) should be 1';
111+
end if;
112+
select * into result from rpm.rpmstrcmp('0foo1bar-1', '0foobar-1');
113+
if result <> -1
114+
then
115+
raise notice 'rpm.rpmstrcmp(0foo1bar-1, 0foobar-1) should be -1';
116+
end if;
117+
select * into result from rpm.rpmstrcmp('0foo2.0', '0foo2');
118+
if result <> 1
119+
then
120+
raise notice 'rpm.rpmstrcmp(0foo2.0, 0foo2) should be 1';
121+
end if;
122+
select * into result from rpm.rpmstrcmp('0foo2.0.0', '0foo2.10.0');
123+
if result <> -1
124+
then
125+
raise notice 'rpm.rpmstrcmp(0foo2.0.0, 0foo2.10.0) should be -1';
126+
end if;
127+
select * into result from rpm.rpmstrcmp('0foo2.0', '0foo2.0.0');
128+
if result <> -1
129+
then
130+
raise notice 'rpm.rpmstrcmp(0foo2.0, 0foo2.0.0) should be -1';
131+
end if;
132+
select * into result from rpm.rpmstrcmp('0foo2.0', '0foo2.10');
133+
if result <> -1
134+
then
135+
raise notice 'rpm.rpmstrcmp(0foo2.0, 0foo2.10) should be -1';
136+
end if;
137+
select * into result from rpm.rpmstrcmp('0foo2.1', '0foo2.10');
138+
if result <> -1
139+
then
140+
raise notice 'rpm.rpmstrcmp(0foo2.1, 0foo2.10) should be -1';
141+
end if;
142+
select * into result from rpm.rpmstrcmp('1.09', '1.9');
143+
if result <> 0
144+
then
145+
raise notice 'rpm.rpmstrcmp(1.09, 1.9) should be 0';
146+
end if;
147+
select * into result from rpm.rpmstrcmp('1.0.8+nmu1', '1.0.8');
148+
if result <> 1
149+
then
150+
raise notice 'rpm.rpmstrcmp(1.0.8+nmu1, 1.0.8) should be 1';
151+
end if;
152+
select * into result from rpm.rpmstrcmp('3.11', '3.10+nmu1');
153+
if result <> 1
154+
then
155+
raise notice 'rpm.rpmstrcmp(3.11, 3.10+nmu1) should be 1';
156+
end if;
157+
select * into result from rpm.rpmstrcmp('0.9j-20080306-4', '0.9i-20070324-2');
158+
if result <> 1
159+
then
160+
raise notice 'rpm.rpmstrcmp(0.9j-20080306-4, 0.9i-20070324-2) should be 1';
161+
end if;
162+
select * into result from rpm.rpmstrcmp('1.2.0~b7-1', '1.2.0~b6-1');
163+
if result <> 1
164+
then
165+
raise notice 'rpm.rpmstrcmp(1.2.0~b7-1, 1.2.0~b6-1) should be 1';
166+
end if;
167+
select * into result from rpm.rpmstrcmp('1.011-1', '1.06-2');
168+
if result <> 1
169+
then
170+
raise notice 'rpm.rpmstrcmp(1.011-1, 1.06-2) should be 1';
171+
end if;
172+
select * into result from rpm.rpmstrcmp('0.0.9+dfsg1-1', '0.0.8+dfsg1-3');
173+
if result <> 1
174+
then
175+
raise notice 'rpm.rpmstrcmp(0.0.9+dfsg1-1, 0.0.8+dfsg1-3) should be 1';
176+
end if;
177+
select * into result from rpm.rpmstrcmp('4.6.99+svn6582-1', '4.6.99+svn6496-1');
178+
if result <> 1
179+
then
180+
raise notice 'rpm.rpmstrcmp(4.6.99+svn6582-1, 4.6.99+svn6496-1) should be 1';
181+
end if;
182+
select * into result from rpm.rpmstrcmp('53', '52');
183+
if result <> 1
184+
then
185+
raise notice 'rpm.rpmstrcmp(53, 52) should be 1';
186+
end if;
187+
select * into result from rpm.rpmstrcmp('0.9.9~pre122-1', '0.9.9~pre111-1');
188+
if result <> 1
189+
then
190+
raise notice 'rpm.rpmstrcmp(0.9.9~pre122-1, 0.9.9~pre111-1) should be 1';
191+
end if;
192+
select * into result from rpm.rpmstrcmp('2.3.2-2+lenny2', '2.3.2-2');
193+
if result <> 1
194+
then
195+
raise notice 'rpm.rpmstrcmp(2.3.2-2+lenny2, 2.3.2-2) should be 1';
196+
end if;
197+
select * into result from rpm.rpmstrcmp('3.8.1-1', '3.8.GA-1');
198+
if result <> 1
199+
then
200+
raise notice 'rpm.rpmstrcmp(3.8.1-1, 3.8.GA-1) should be 1';
201+
end if;
202+
select * into result from rpm.rpmstrcmp('1.0.1+gpl-1', '1.0.1-2');
203+
if result <> 1
204+
then
205+
raise notice 'rpm.rpmstrcmp(1.0.1+gpl-1, 1.0.1-2) should be 1';
206+
end if;
207+
select * into result from rpm.rpmstrcmp('1a', '1000a');
208+
if result <> -1
209+
then
210+
raise notice 'rpm.rpmstrcmp(1a, 1000a) should be -1';
211+
end if;
212+
213+
end;
214+
$$

0 commit comments

Comments
 (0)