3 * Test rig for versioncmp
5 * (c) 2008 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
29 #include "versioncmp.h"
33 RV0 = NROUT, RV1, NREG
36 static void test_versioncmp(const struct tvec_reg *in, struct tvec_reg *out,
38 { out[RRC].v.i = versioncmp(in[RV0].v.str.p, in[RV1].v.str.p); }
40 static int swap_test(struct tvec_state *tv)
45 tv->test->fn(tv->in, tv->out, 0); tvec_check(tv, "vanilla");
46 rt = tv->in[RV0]; tv->in[RV0] = tv->in[RV1]; tv->in[RV1] = rt;
47 tv->in[RRC].v.i = -tv->in[RRC].v.i;
48 tv->test->fn(tv->in, tv->out, 0); tvec_check(tv, "swapped");
52 static const struct tvec_irange cmp_range = { -1, +1 };
53 static const struct tvec_regdef versioncmp_regs[] = {
54 { "v0", RV0, &tvty_string, 0 },
55 { "v1", RV1, &tvty_string, 0 },
56 { "rc", RRC, &tvty_int, 0, { &cmp_range } },
60 static const struct tvec_test tests[] = {
61 { "versioncmp", versioncmp_regs, 0, swap_test, test_versioncmp },
65 static const struct tvec_info testinfo =
66 { tests, NROUT, NREG, sizeof(struct tvec_reg) };
68 int main(int argc, char *argv[])
69 { return (tvec_main(argc, argv, &testinfo, 0)); }
71 /*----- That's all, folks -------------------------------------------------*/