+/*----- Test rig ----------------------------------------------------------*/
+
+#ifdef TEST_RIG
+
+#include <mLib/testrig.h>
+
+static int vfact(dstr *v)
+{
+ unsigned long x = *(unsigned long *)v[0].buf;
+ mp *fx = *(mp **)v[1].buf;
+ mp *y = mp_factorial(x);
+ int ok = 1;
+ if (!MP_EQ(fx, y)) {
+ fprintf(stderr, "factorial failed\n");
+ MP_FPRINTF(stderr, (stderr, "%lu! = ", x), fx);
+ MP_EPRINT("result", y);
+ ok = 0;
+ }
+ mp_drop(fx);
+ mp_drop(y);
+ assert(mparena_count(MPARENA_GLOBAL) == 0);
+ return (ok);
+}
+
+static test_chunk tests[] = {
+ { "factorial", vfact, { &type_ulong, &type_mp, 0 } },
+ { 0, 0, { 0 } }
+};
+
+int main(int argc, char *argv[])
+{
+ test_run(argc, argv, tests, SRCDIR "/tests/mp");
+ return (0);
+}
+
+#endif
+