int
main(int argc, char *const *argv)
{
	plan_tests(6);

	ok(tests_begin(argc, argv), "setup");

	UInt32 didGetNotification = 0;
	ok_status(SecKeychainAddCallback(callbackFunction, kSecAddEventMask,
		&didGetNotification), "add callback");

	SecKeychainRef keychain;
	ok_status(SecKeychainCreate("test", 4, "test", FALSE, NULL, &keychain),
			"create keychain");
	SecKeychainItemRef itemRef;
	ok_status(SecKeychainAddGenericPassword(keychain,
		sizeof(account), account,
		sizeof(service), service,
		sizeof(password), password,
		&itemRef),
		"add generic password, release and wait for callback");
	//checkContent(itemRef);
	CFRelease(itemRef);
	CFRelease(keychain);

	if (argc > 1 && !strcmp(argv[1], "-l")) {
		printf("pid: %d\n", getpid());
		sleep(100);
	}
	ok(tests_end(1), "cleanup");
	ok_leaks("leaks");

	return 0;
}
Esempio n. 2
0
int
main (int argc, char **argv)
{
  int i;
  int reps = 20;
  gmp_randstate_ptr rands;
  mpz_t bs, x, nxtp, ref_nxtp;
  unsigned long size_range;

  tests_start();
  rands = RANDS;

  run ("2", 1000, "0x1ef7", diff1);

  run ("3", 1000 - 1, "0x1ef7", NULL);

  run ("0x8a43866f5776ccd5b02186e90d28946aeb0ed914", 50,
       "0x8a43866f5776ccd5b02186e90d28946aeb0eeec5", diff3);

  run ("0x10000000000000000000000000000000000000", 50,
       "0x100000000000000000000000000000000010ab", diff4);

  run ("0x1c2c26be55317530311facb648ea06b359b969715db83292ab8cf898d8b1b", 50,
       "0x1c2c26be55317530311facb648ea06b359b969715db83292ab8cf898da957", diff5);

  mpz_init (bs);
  mpz_init (x);
  mpz_init (nxtp);
  mpz_init (ref_nxtp);

  if (argc == 2)
     reps = atoi (argv[1]);

  for (i = 0; i < reps; i++)
    {
      mpz_urandomb (bs, rands, 32);
      size_range = mpz_get_ui (bs) % 8 + 2; /* 0..1024 bit operands */

      mpz_urandomb (bs, rands, size_range);
      mpz_rrandomb (x, rands, mpz_get_ui (bs));

/*      gmp_printf ("%ld: %Zd\n", mpz_sizeinbase (x, 2), x); */

      mpz_nextprime (nxtp, x);
      refmpz_nextprime (ref_nxtp, x);
      if (mpz_cmp (nxtp, ref_nxtp) != 0)
	abort ();
    }

  mpz_clear (bs);
  mpz_clear (x);
  mpz_clear (nxtp);
  mpz_clear (ref_nxtp);

  tests_end ();
  return 0;
}
Esempio n. 3
0
int 
main (int argc, char **argv)
{
    char str[1000];
    gmp_randstate_t rnd; 
    mpz_t x, y, z;
    int i, j, k, s;

    tests_start ();
    gmp_randinit_default (rnd);
    mpz_init(x);
    mpz_init(y);
    mpz_init(z);
    for( i = 0 ; i < sizeof(tests1) / sizeof(tests1[0]) ; ++i )
    {
      mpz_ui_pow_ui(x, 10, tests1[i].pow10);
      mpz_next_prime_candidate(y, x, rnd);
      mpz_sub(y, y, x);
      j = mpz_get_ui(y);
      if(j != tests1[i].np_off)
      {
          printf("\nnext_likely_prime(10^%d) - 10^%d: expected %d but got %d", 
              tests1[i].pow10, tests1[i].pow10, tests1[i].np_off, j);
          abort();
      }
    }

    for( i = 0 ; i < sizeof(tests2) / sizeof(tests2[0]) ; ++i )
    {
      mpz_ui_pow_ui(x, 10, tests2[i].pow10);
      mpz_set(y, x);
      s = j = 0;
      for( ; ; )
      {
          mpz_next_prime_candidate(y, y, rnd);
          mpz_sub(z, y, x);
          k = mpz_get_si(z);
          if(k >= 1000)
              break;
          j++;
          s += k * k;
      }
      if(j != tests2[i].count || s != tests2[i].sumsq)
      {
          printf("\nnext_likely_prime failed test2[%d], expected %d and %d but got %d and %d", 
              i, tests2[i].count, tests2[i].sumsq, j, s);
          abort();
      }
    }
      
    gmp_randclear (rnd);
    mpz_clear(z);
    mpz_clear(y);
    mpz_clear(x);
    tests_end ();
    exit (0);
}
Esempio n. 4
0
int
main (void)
{
  tests_start ();

  check_ui_range ();

  tests_end ();
  exit (0);
}
int
main (int argc, char **argv)
{
  tests_start ();

  check_random (argc, argv);

  tests_end ();
  exit (0);
}
int
main (void)
{
  tests_start ();

  check_consistency ();

  tests_end ();
  exit (0);
}
Esempio n. 7
0
int
main (void)
{
  tests_start ();

  check_data ();

  tests_end ();
  exit (0);
}
Esempio n. 8
0
int
main (void)
{
  tests_start ();

  check_dc_divappr_q ();
  
  tests_end ();
  exit (0);
}
Esempio n. 9
0
int
main (void)
{
  tests_start ();

  check_samples ();

  tests_end ();
  exit (0);
}
Esempio n. 10
0
int
main (void)
{
  tests_start ();

  check_dc_div_qr_n ();
  
  tests_end ();
  exit (0);
}
Esempio n. 11
0
int
main (void)
{
  tests_start ();

  check_reuse ();

  tests_end ();
  exit (0);
}
Esempio n. 12
0
int
main (int argc, char *argv[])
{
  tests_start ();

  check_data ();

  tests_end ();
  exit (0);
}
int
main (void)
{
  tests_start ();

  /* check_sample (); */

  tests_end ();
  exit (0);
}
Esempio n. 14
0
int
main (void)
{
  tests_start ();

  check_sb_div_q ();
  
  tests_end ();
  exit (0);
}
Esempio n. 15
0
int
main (void)
{
  tests_start ();

  check_various ();

  tests_end ();
  exit (0);
}
Esempio n. 16
0
int
main (int argc, char *argv[])
{
  tests_start ();

  call_rand_algs (check_one);

  tests_end ();
  exit (0);
}
Esempio n. 17
0
int
main (int argc, char *argv[])
{
  tests_start ();

  check_infinity ();

  tests_end ();
  exit (0);
}
Esempio n. 18
0
int
main (int argc, char **argv)
{
  mp_ptr ap, bp, rp, refp;
  gmp_randstate_ptr rands;
  int test;
  TMP_DECL;
  TMP_MARK;

  tests_start ();
  rands = RANDS;

  ap = TMP_ALLOC_LIMBS (MAX_N);
  bp = TMP_ALLOC_LIMBS (MAX_N);
  rp = TMP_ALLOC_LIMBS (MAX_N + 2);
  refp = TMP_ALLOC_LIMBS (MAX_N + 2);

  for (test = 0; test < COUNT; test++)
    {
      mp_size_t an, bn, rn;
      unsigned size_log;

      size_log = 1 + gmp_urandomm_ui (rands, SIZE_LOG);
      an = 1 + gmp_urandomm_ui(rands, 1L << size_log);

      size_log = 1 + gmp_urandomm_ui (rands, SIZE_LOG);
      bn = 1 + gmp_urandomm_ui(rands, 1L << size_log);

      /* Make sure an >= bn */
      if (an < bn)
	MP_SIZE_T_SWAP (an, bn);

      mpn_random2 (ap, an);
      mpn_random2 (bp, bn);

      refmpn_mulmid (refp, ap, an, bp, bn);
      mpn_mulmid (rp, ap, an, bp, bn);

      rn = an + 3 - bn;
      if (mpn_cmp (refp, rp, rn))
	{
	  printf ("ERROR in test %d, an = %d, bn = %d, rn = %d\n",
		  test, (int) an, (int) bn, (int) rn);
	  printf("a: "); mpn_dump (ap, an);
	  printf("b: "); mpn_dump (bp, bn);
	  printf("r:   "); mpn_dump (rp, rn);
	  printf("ref: "); mpn_dump (refp, rn);

	  abort();
	}
    }
  TMP_FREE;
  tests_end ();
  return 0;
}
Esempio n. 19
0
int
main (int argc, char *argv[])
{
  tests_start ();
  mp_trace_base = -16;

  check_sequence (argc, argv);

  tests_end ();
  exit (0);
}
Esempio n. 20
0
int
main (void)
{
  tests_start ();

  check_mem ();
  check_random ();

  tests_end ();
  exit (0);
}
Esempio n. 21
0
int
main (int argc, char **argv)
{
  tests_start ();
  mp_trace_base = -16;

  check_rand ();

  tests_end ();
  exit (0);
}
Esempio n. 22
0
int
main (void)
{
  tests_start ();

  mp_trace_base = -16;
  check_data ();

  tests_end ();
  exit (0);
}
Esempio n. 23
0
int
main (void)
{
  tests_start ();

  check_data ();

  unlink (FILENAME);
  tests_end ();
  exit (0);
}
Esempio n. 24
0
int
main (void)
{
  tests_start ();
  mp_trace_base = -16;

  check_twobits ();
  check_rand ();

  tests_end ();
  exit (0);
}
Esempio n. 25
0
File: bit.c Progetto: mahdiz/mpclib
int
main (int argc, char *argv[])
{
  tests_start ();

  check_tstbit ();
  check_random (argc, argv);
  check_single ();

  tests_end ();
  exit (0);
}
Esempio n. 26
0
int
main (void)
{
  tests_start ();

  check_onebit ();
  check_data ();
  check_random ();

  tests_end ();
  exit (0);
}
Esempio n. 27
0
int
main (void)
{
#if GMP_NAIL_BITS == 0		/* bogus test criteria cause nails to fail */
  tests_start ();

  check_data ();

  tests_end ();
#endif
  exit (0);
}
Esempio n. 28
0
int
main (void)
{
  tests_start ();

  check_various ();
  check_rand ();
  check_reuse_three ();

  tests_end ();
  exit (0);
}
Esempio n. 29
0
int
main (void)
{
    tests_start ();
    mp_trace_base = -16;

    check_add_1 ();
    check_sub_1 ();

    tests_end ();
    exit (0);
}
Esempio n. 30
0
int
main (void)
{
  memcpy (&initial_cpuvec, &__gmpn_cpuvec, sizeof (__gmpn_cpuvec));

  tests_start ();

  check_functions ();
  check_thresholds ();

  tests_end ();
  exit (0);
}