3 * Generate test cases for %$\gf{2}[x]$% arithmetic
5 * (c) 2000 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb 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 * Catacomb 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 Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 /*----- External units ----------------------------------------------------*/
32 /*----- Global variables --------------------------------------------------*/
34 global op = "+", n = 40, bits = 128;
36 /*----- Main code ---------------------------------------------------------*/
38 dummy = config("lib_debug", -1);
44 for (i = 0; i < n; i++) {
46 /* --- Select the inputs and produce the outputs --- */
51 a = gf(random(1 << bits));
52 b = gf(random(1 << bits));
53 l = list(a, b, a + b);
56 a = gf(random(1 << bits));
57 b = gf(random(1 << bits));
58 l = list(a, b, a * b);
61 a = gf(random(1 << bits));
65 a = gf(random(1 << (bits + random(bits))));
66 b = gf(random(1 << bits));
67 l = list(a, b, a / b, a % b);
70 exit "unknown operator";
74 /* --- Output the test vector --- *
76 * Be careful to ensure that it has an even number of hex digits in each
80 for (j = 0; j < size(l); j++) {
81 x = strprintf("%x", l[[j]].x);
83 x = substr(x, 3, strlen(x) - 2);
96 /*----- That's all, folks -------------------------------------------------*/