XBPS Library API 20250615
The X Binary Package System
cmpver/main.c
1/*-
2 * Copyright (c) 2012 Juan Romero Pardines.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *-
25 */
26
27#include <atf-c.h>
28#include <xbps.h>
29
30ATF_TC(cmpver_test);
31
32ATF_TC_HEAD(cmpver_test, tc)
33{
34 atf_tc_set_md_var(tc, "descr", "Test xbps_cmpver conditions");
35}
36
37ATF_TC_BODY(cmpver_test, tc)
38{
39 ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0", "foo-1.0"), 0);
40 ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0", "foo-1.0_1"), -1);
41 ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0_1", "foo-1.0"), 1);
42 ATF_REQUIRE_EQ(xbps_cmpver("foo-2.0rc2", "foo-2.0rc3"), -1);
43 ATF_REQUIRE_EQ(xbps_cmpver("foo-2.0rc3", "foo-2.0rc2"), 1);
44 ATF_REQUIRE_EQ(xbps_cmpver("foo-129", "foo-129_1"), -1);
45 ATF_REQUIRE_EQ(xbps_cmpver("foo-blah-100dpi-21", "foo-blah-100dpi-21_0"), 0);
46 ATF_REQUIRE_EQ(xbps_cmpver("foo-blah-100dpi-21", "foo-blah-100dpi-2.1"), 1);
47 ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0.1", "foo-1.0_1"), 1);
48}
49
50ATF_TP_ADD_TCS(tp)
51{
52 ATF_TP_ADD_TC(tp, cmpver_test);
53 return atf_no_error();
54}
int xbps_cmpver(const char *pkg1, const char *pkg2)
Definition dewey.c:273