#define __STDC_LIMIT_MACROS
#include "testing.h"
#include <gf2e_cxx/finite_field_givaro.h>
using namespace M4RIE;
int test_equality(
gf2e *ff, rci_t m, rci_t n) {
int fail_ret = 0;
mzed_t *A0 = random_mzed_t(ff, m, n);
mzed_set_canary(A1);
mzed_set_canary(A2);
mzed_set_canary(A3);
rci_t r3 = 0;
}
m4rie_check( r0 == r1);
m4rie_check( r1 == r2);
m4rie_check( r2 == r3);
m4rie_check( r3 == r0);
} else {
m4rie_check( r2 == r0);
}
m4rie_check( mzed_canary_is_alive(A0) );
m4rie_check( mzed_canary_is_alive(A1) );
m4rie_check( mzed_canary_is_alive(A2) );
m4rie_check( mzed_canary_is_alive(A3) );
return fail_ret;
}
int test_batch(
gf2e *ff, rci_t m, rci_t n) {
int fail_ret = 0;
printf(
"elim: k: %2d, minpoly: 0x%03x m: %5d, n: %5d ",(
int)ff->
degree, (
unsigned int)ff->
minpoly, (
int)m, (
int)n);
if(m == n) {
m4rie_check( test_equality(ff, m, n) == 0); printf("."); fflush(0);
printf(" ");
} else {
m4rie_check( test_equality(ff, m, n) == 0); printf("."); fflush(0);
m4rie_check( test_equality(ff, n, m) == 0); printf("."); fflush(0);
}
if (fail_ret == 0)
printf(" passed\n");
else
printf(" FAILED\n");
return fail_ret;
}
int main(int argc, char **argv) {
srandom(17);
int fail_ret = 0;
for(int k=2; k<=10; k++) {
Givaro::GFqDom<int> GF = Givaro::GFqDom<int>(2,k);
FiniteField *F = (FiniteField*)&GF;
ff[k] = gf2e_init_givgfq(F);
}
for(int k=2; k<=10; k++) {
fail_ret += test_batch(ff[k], 2, 5);
fail_ret += test_batch(ff[k], 5, 10);
fail_ret += test_batch(ff[k], 1, 1);
fail_ret += test_batch(ff[k], 1, 2);
fail_ret += test_batch(ff[k], 11, 12);
fail_ret += test_batch(ff[k], 21, 22);
fail_ret += test_batch(ff[k], 13, 2);
fail_ret += test_batch(ff[k], 32, 33);
fail_ret += test_batch(ff[k], 63, 64);
fail_ret += test_batch(ff[k], 127, 128);
fail_ret += test_batch(ff[k], 200, 20);
fail_ret += test_batch(ff[k], 1, 1);
fail_ret += test_batch(ff[k], 1, 3);
fail_ret += test_batch(ff[k], 11, 13);
fail_ret += test_batch(ff[k], 21, 23);
fail_ret += test_batch(ff[k], 13, 90);
fail_ret += test_batch(ff[k], 32, 34);
fail_ret += test_batch(ff[k], 63, 65);
fail_ret += test_batch(ff[k], 127, 129);
fail_ret += test_batch(ff[k], 200, 112);
fail_ret += test_batch(ff[k], 10, 200);
};
for(int k=2; k<=10; k++) {
}
return fail_ret;
}