Exemplo n.º 1
0
int main()
{

test_valor_maximo2();
test_a_eh_maior();
test_valor_maximo3();
test_valor_maximo4();
test_a_esta_meio();
test_resto_divisao();
test_resto_divisao_maior();
test_eh_par();
test_eh_mult3();
test_eh_mult();
test_eh_sobra31_div5();
test_eh_par_n46();
test_satisfaz_situacao();
test_modulo();
test_operacao();
test_operacao2();
test_ambos_3_ou_ambos_5();
test_restos_iguais();
test_div_35();
t.total();
  return 0;
}
Exemplo n.º 2
0
void
test_main (void)
{
  const char *nettle_test_seed;
  gmp_randstate_t rands;
  unsigned count = COUNT;
  unsigned i;

  gmp_randinit_default (rands);

  test_fixed ();

  for (i = 0; ecc_curves[i]; i++)
    {
      test_patterns ("p", &ecc_curves[i]->p);
      test_patterns ("q", &ecc_curves[i]->p);
    }

#if !NETTLE_USE_MINI_GMP
  nettle_test_seed = getenv ("NETTLE_TEST_SEED");
  if (nettle_test_seed && *nettle_test_seed)
    {
      mpz_t seed;
      mpz_init (seed);
      if (mpz_set_str (seed, nettle_test_seed, 0) < 0
	  || mpz_sgn (seed) < 0)
	die ("Invalid NETTLE_TEST_SEED: %s\n",
	     nettle_test_seed);
      if (mpz_sgn (seed) == 0)
	get_random_seed (seed);
      fprintf (stderr, "Using NETTLE_TEST_SEED=");
      mpz_out_str (stderr, 10, seed);
      fprintf (stderr, "\n");

      gmp_randseed (rands, seed);
      mpz_clear (seed);
      count *= 20;
    }
#endif /* !NETTLE_USE_MINI_GMP */

  for (i = 0; ecc_curves[i]; i++)
    {
      test_modulo (rands, "p", &ecc_curves[i]->p, count);
      test_modulo (rands, "q", &ecc_curves[i]->q, count);
    }
  gmp_randclear (rands);
}
Exemplo n.º 3
0
int main() {
    test_valor_maximo4();
    test_modulo();
    test_ambos_3_ou_ambos_5();
    testa_impares_3_500();
    testa_potencia();
    t.total();
    return 0;
}
Exemplo n.º 4
0
void
test_main (void)
{
  gmp_randstate_t rands;
  unsigned i;

  gmp_randinit_default (rands);
  for (i = 0; ecc_curves[i]; i++)
    {
      if (ecc_curves[i]->p.sqrt)
	test_modulo (rands, &ecc_curves[i]->p);
    }
  gmp_randclear (rands);
}
Exemplo n.º 5
0
void test_all_modulo() {
    test_modulo(nan, nan, nan, "nan % nan");
    test_modulo(nan, three, nan, "nan % 3");
    test_modulo(nannan, nannan, nan, "nannan % nannan");
    test_modulo(nannan, one, nan, "nannan % 1");
    test_modulo(zero, nan, zero, "0 % nan");
    test_modulo(zero, nannan, zero, "0 % nannan");
    test_modulo(zero, zero, zero, "0 % 0");
    test_modulo(zero, zip, zero, "zero % zip");
    test_modulo(zero, one, zero, "0 % 1");
    test_modulo(zero, maxnum, zero, "0 % maxnum");
    test_modulo(zip, nan, zero, "zip % nan");
    test_modulo(zip, nannan, zero, "zip % nannan");
    test_modulo(zip, zero, zero, "zip % zero");
    test_modulo(zip, zip, zero, "zip % zip");
    test_modulo(one, negative_one, zero, "1 % -1");
    test_modulo(one, zero, nan, "1 % 0");
    test_modulo(one, one, zero, "1 % 1");
    test_modulo(one, two, one, "1 % 2");
    test_modulo(one, three, one, "1 % 3");
    test_modulo(one, maxint, one, "one % maxint");
    test_modulo(dec64_new(10, -1), maxint, dec64_new(10, -1), "one % maxint");
    test_modulo(negative_one, one, zero, "-1 % 1");
    test_modulo(two, three, two, "2 % 3");
    test_modulo(dec64_new(20000000000000000, -16), three, two, "2 % 3");
    test_modulo(two, dec64_new(30000000000000000, -16), two, "2 % 3 alias");
    test_modulo(three, three, zero, "3 % 3");
    test_modulo(pi, e, dec64_new(4233108251307480, -16), "pi % e");
    test_modulo(pi, pi, zero, "pi % pi");
    test_modulo(pi, negative_pi, zero, "pi % -pi");
    test_modulo(negative_pi, pi, zero, "-pi % pi");
    test_modulo(negative_pi, negative_pi, zero, "-pi % -pi");
    test_modulo(four, three, one, "4 % 3");
    test_modulo(dec64_new(40000000000000000, -16), dec64_new(3000000000000000, -15), one, "4 % 3");
    test_modulo(dec64_new(40000000000000000, -16), dec64_new(30000000000000000, -16), one, "4 % 3");
    test_modulo(five, three, two, "5 % 3");
    test_modulo(five, dec64_new(-30000000000000000, -16), negative_one, "5 % -3 alias");
    test_modulo(five, dec64_new(-3, 0), dec64_new(-1, 0), "5 % -3");
    test_modulo(dec64_new(-5, 0), three, one, "-5 % 3");
    test_modulo(dec64_new(-5, 0), dec64_new(-3, 0), dec64_new(-2, 0), "-5 % -3");
    test_modulo(dec64_new(-5, 0), dec64_new(-30000000000000000, -16), dec64_new(-2, 0), "-5 % -3");
    test_modulo(dec64_new(-50000000000000000, -16), three, one, "-5 % 3");
    test_modulo(dec64_new(-50000000000000000, -16), dec64_new(-30000000000000000, -16), dec64_new(-2, 0), "-5 % -3");
    test_modulo(six, nan, nan, "6 % nan");
    test_modulo(six, three, zero, "6 % 3");
    test_modulo(maxint, epsilon, zero, "maxint % epsilon");
    test_modulo(maxnum, epsilon, nan, "maxnum % epsilon");
    test_modulo(maxnum, maxnum, zero, "maxnum % maxnum");
}