chiark / gitweb /
@@@ so much mess
[mLib] / utils / t / versioncmp-test.c
index 1368e00aa7170d3c1f614e647523cb79983a219d..0fb344c1559f7c69738560cb66aa194b7f6b6afe 100644 (file)
@@ -37,28 +37,28 @@ static void test_versioncmp(const struct tvec_reg *in, struct tvec_reg *out,
                            void *ctx)
   { out[RRC].v.i = versioncmp(in[RV0].v.str.p, in[RV1].v.str.p); }
 
-static int swap_test(struct tvec_state *tv)
+static void swap_test(struct tvec_state *tv, tvec_testfn *fn, void *ctx)
 {
   struct tvec_reg rt;
 
-  tv->st = '.';
-  tv->test->fn(tv->in, tv->out, 0); tvec_check(tv, "vanilla");
+  fn(tv->in, tv->out, 0); tvec_check(tv, "vanilla");
+  tvec_resetoutputs(tv);
   rt = tv->in[RV0]; tv->in[RV0] = tv->in[RV1]; tv->in[RV1] = rt;
   tv->in[RRC].v.i = -tv->in[RRC].v.i;
-  tv->test->fn(tv->in, tv->out, 0); tvec_check(tv, "swapped");
-  return (0);
+  fn(tv->in, tv->out, 0); tvec_check(tv, "swapped");
 }
+static const struct tvec_env swap_testenv = { 0, 0, 0, 0, swap_test, 0, 0 };
 
 static const struct tvec_irange cmp_range = { -1, +1 };
 static const struct tvec_regdef versioncmp_regs[] = {
   { "v0", RV0, &tvty_string, 0 },
   { "v1", RV1, &tvty_string, 0 },
   { "rc", RRC, &tvty_int, 0, { &cmp_range } },
-  { 0, 0, 0 }
+  { 0, 0, 0, 0 }
 };
 
 static const struct tvec_test tests[] = {
-  { "versioncmp", versioncmp_regs, 0, swap_test, test_versioncmp },
+  { "versioncmp", versioncmp_regs, &swap_testenv, test_versioncmp },
   { 0, 0, 0, 0 }
 };