Ejemplo n.º 1
0
int
main()
{
  init_random_ness ();
  test_area ();
  test_intersect ();
  test_equal ();
  test_overlap_funcs ();
  test_basic_fitting ();

  test_regions_okay ();
  test_region_fitting ();

  test_clamping_to_region ();
  test_clipping_to_region ();
  test_shoving_into_region ();

  /* And now the functions dealing with edges more than boxes */
  test_find_onscreen_edges ();
  test_find_nonintersected_monitor_edges ();

  /* And now the misfit functions that don't quite fit in anywhere else... */
  test_gravity_resize ();
  test_find_closest_point_to_line ();

  printf ("All tests passed.\n");
  return 0;
}
Ejemplo n.º 2
0
int main (int argc, char *argv[])
{
  bool result= true;

  result = result && test_equality_bool(true, test_new_piece(), "new_piece");
  result = result && test_equality_bool(true, test_intersect(), "intersect");
  result = result && test_equality_bool(true, test_move(), "move");
  result = result && test_equality_bool(true, test_copy(), "copy");

  if (result){
    printf("Youpi !\n");
    return EXIT_SUCCESS;
  }else{
    return EXIT_FAILURE;
  }
}
Ejemplo n.º 3
0
/*************************************************************************
test_many_intersect:
  In: an array of reactions we're testing
      a probability multiplier depending on how many timesteps we've
        moved at once (1.0 means one timestep)
      the number of elements in the array of reactions
      placeholder for the chosen pathway in the reaction (return value)
  Out: RX_NO_RX if no reaction occurs (assume reflection)
       index in the reaction array if reaction does occur
  Note: If not RX_NO_RX, and not the trasparency shortcut, then we
        update counters assuming the reaction will take place.
*************************************************************************/
int test_many_intersect(struct rxn **rx, double scaling, int n,
                        int *chosen_pathway, struct rng_state *rng) {

  if (n == 1)
    return test_intersect(rx[0], scaling, rng);

  // array of cumulative rxn probabilities
  double rxp[n];
  rxp[0] = rx[0]->max_fixed_p / scaling;
  int i; /* index in the array of reactions - return value */
  for (i = 1; i < n; i++) {
    rxp[i] = rxp[i - 1] + rx[i]->max_fixed_p / scaling;
  }

  double p;
  if (rxp[n - 1] > 1.0) {
    double f = rxp[n - 1] - 1.0; /* Number of failed reactions */
    for (i = 0; i < n; i++)      /* Distribute failures */
    {
      rx[i]->n_skipped +=
          f * (rx[i]->cum_probs[rx[i]->n_pathways - 1]) / rxp[n - 1];
    }
    p = rng_dbl(rng) * rxp[n - 1];
  } else {
    p = rng_dbl(rng);
    if (p > rxp[n - 1])
      return RX_NO_RX;
  }

  /* Pick the reaction that happens */
  i = binary_search_double(rxp, p, n - 1, 1);

  struct rxn *my_rx = rx[i];

  if (i > 0)
    p = (p - rxp[i - 1]);
  p = p * scaling;

  /* Now pick the pathway within that reaction */
  *chosen_pathway =
      binary_search_double(my_rx->cum_probs, p, my_rx->n_pathways - 1, 1);

  return i;
}
Ejemplo n.º 4
0
my_bool do_test(uint bitsize)
{
  MY_BITMAP map;
  uint32 buf[MAX_TESTED_BITMAP_SIZE];
  if (bitmap_init(&map, buf, bitsize, FALSE))
  {
    diag("init error for bitsize %d", bitsize);
    goto error;
  }
  if (test_set_get_clear_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_flip_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_get_all_bits(&map, bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_compare_operators(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_count_bits_set(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_get_first_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_get_next_bit(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_prefix(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_compare(&map,bitsize))
    goto error;
  bitmap_clear_all(&map);
  if (test_intersect(&map,bitsize))
    goto error;
  return FALSE;
error:
  return TRUE;
}
Ejemplo n.º 5
0
int
main (int argc, char **argv)
{
    if (argc < 2)
        usage ();

    if (!strcmp (argv[1], "testpat"))
        make_testpat ();
    else if (!strcmp (argv[1], "gradient"))
        test_gradient ();
    else if (!strcmp (argv[1], "dist"))
        test_dist ();
    else if (!strcmp (argv[1], "dash"))
        test_dash ();
    else if (!strcmp (argv[1], "intersect"))
        test_intersect ();
    else if (!strcmp (argv[1], "intersect1"))
        test_intersection();
    else
        usage ();
    return 0;
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
    bool result = true;
    piece no_piece = NULL;

    printf("result of test error\n");
    test_equality_int(0, 1, "error test_equality_int ");
    test_equality_bool(true, false, "error test_equality_bool ");
    test_failure_piece(no_piece);
    printf("----------------------------------------------------------\n");
    delete_piece(no_piece);
    result = result && test_equality_bool(true, test_new_piece(), "new_piece");
    result = result && test_equality_bool(true, test_intersect(), "intersect");
    result = result && test_equality_bool(true, test_move(), "move");
    result = result && test_equality_bool(true, test_copy(), "copy");


    if (result) {
        printf("Youpi !\n");
        return EXIT_SUCCESS;
    } else
        return EXIT_FAILURE;
}