Пример #1
0
/*
 *	This routine initializes the decks from the data file,
 * which it opens.
 */
void
init_decks()
{
	if ((deckf = fopen(cardfile, "r")) == NULL)
file_err:
		err(1, "%s", cardfile);
	if (fread(&deck[0].num_cards, sizeof(deck[0].num_cards), 1, deckf) != 1)
		goto file_err;
	if (fread(&deck[0].top_card, sizeof(deck[0].top_card), 1, deckf) != 1)
		goto file_err;
	if (fread(&deck[0].gojf_used, sizeof(deck[0].gojf_used), 1, deckf) != 1)
		goto file_err;
	deck[0].num_cards = ntohs(deck[0].num_cards);
	deck[0].top_card = ntohs(deck[0].top_card);

	if (fread(&deck[1].num_cards, sizeof(deck[1].num_cards), 1, deckf) != 1)
		goto file_err;
	if (fread(&deck[1].top_card, sizeof(deck[1].top_card), 1, deckf) != 1)
		goto file_err;
	if (fread(&deck[1].gojf_used, sizeof(deck[1].gojf_used), 1, deckf) != 1)
		goto file_err;
	deck[1].num_cards = ntohs(deck[1].num_cards);
	deck[1].top_card = ntohs(deck[1].top_card);

	set_up(&CC_D);
	set_up(&CH_D);
}
Пример #2
0
/*
 *	This routine initializes the decks from the data file,
 * which it opens.
 */
init_decks() {

	if ((deckf=fopen(cardfile, "r")) == NULL) {
file_err:
		perror(cardfile);
		exit(1);
	}
	if (fread(deck, sizeof (DECK), 2, deckf) != 2)
		goto file_err;
	set_up(&CC_D);
	set_up(&CH_D);
}
Пример #3
0
/**
 *test put long keys into Btree
 */
TEST(KeyBtree_Put_Char_Test, put_07_longkey)
{
	set_up();
	int32_t iRet = 0;
	int32_t iValue = 0;
	int32_t iSuccess = 0;
	int32_t iFail = 0;
	charBtree btree(sizeof(char*));

	for (int32_t iLoop = 0; iLoop < TEST_COUNT; iLoop ++)
	{
		/* malloc */
		pstrKey[ iLoop ] = (char *)malloc( TEST_SIZE );
		/* Set the flag for free */
		iFlag = 1;
		/* Create the key */
		get_next_random_value( iValue );
		sprintf( pstrKey[ iLoop ], "%08x", iValue );
		/* Put the key-value pair */
		iRet = btree.put( pstrKey[ iLoop ], iLoop + 1 );
		if (iRet == ERROR_CODE_OK)
		{
			iSuccess ++;
		}
		else
		{
			iFail ++;
		}
	}
	EXPECT_EQ( iFail, 0 );
	EXPECT_EQ( iSuccess, btree.get_object_count() );
	tear_down();
	btree.clear();
}
Пример #4
0
static void test_clist_remove(void)
{
    list_node_t *list = &test_clist;

    for (int i = 0; i < 3; i++) {
        set_up();
        test_clist_add_three();
        clist_remove(list, &(tests_clist_buf[i]));

        for (int j = 0; j < 3; j++) {
            if (i == j) {
                TEST_ASSERT_NULL(clist_find(list, &(tests_clist_buf[j])));
            }
            else {
                TEST_ASSERT(clist_find(list, &(tests_clist_buf[j])) == &(tests_clist_buf[j]));
            }
        }
    }

    /* list now contains 0, 1 */
    TEST_ASSERT(list->next == &(tests_clist_buf[1]));
    TEST_ASSERT(list->next->next == &(tests_clist_buf[0]));

    clist_remove(list, &(tests_clist_buf[1]));
    TEST_ASSERT(list->next == &(tests_clist_buf[0]));
    TEST_ASSERT(list->next->next == &(tests_clist_buf[0]));

    clist_remove(list, &(tests_clist_buf[0]));
    TEST_ASSERT_NULL(list->next);
}
Пример #5
0
bool test_move() {
  bool result = true;
  piece p = new_piece_rh(0, 0, true, true);
  set_up();
  for (int dist = 1; dist < NB_PIECES; dist++)
    for (int i=0; i < NB_PIECES; i++) {
      copy_piece(pieces[i],p);
      move_piece(p, LEFT, dist);
      if (is_horizontal(pieces[i]))
        result = result && test_equality_int(get_x(pieces[i])-dist,get_x(p),"move LEFT");
      else
        result = result && test_equality_int(get_x(pieces[i]),get_x(p),"move LEFT");
      copy_piece(pieces[i],p);
      move_piece(p, RIGHT, dist);
      if (is_horizontal(pieces[i]))
        result = result && test_equality_int(get_x(pieces[i])+dist,get_x(p),"move RIGHT");
      else
        result = result && test_equality_int(get_x(pieces[i]),get_x(p),"move RIGHT");
      copy_piece(pieces[i],p);
      move_piece(p, UP, dist);
      if (!is_horizontal(pieces[i]))
        result = result && test_equality_int(get_y(pieces[i])+dist,get_y(p),"move UP");
      else
        result = result && test_equality_int(get_y(pieces[i]),get_y(p),"move UP");
      copy_piece(pieces[i],p);
      move_piece(p, DOWN, dist);
      if (!is_horizontal(pieces[i]))
        result = result && test_equality_int(get_y(pieces[i])-dist,get_y(p),"move DOWN");
      else
        result = result && test_equality_int(get_y(pieces[i]),get_y(p),"move DOWN");
    }
  tear_down();
  delete_piece(p);
  return result;
}
Пример #6
0
// ----------------------------------------------------------------
static char* test_het_initial_pairing() {
	printf("----------------------------------------------------------------\n");
	printf("test_het_initial_pairing enter\n");
	slls_t* pleft_field_names;
	lrec_reader_t* preader;
	set_up(make_records_het(), &pleft_field_names, &preader);
	join_bucket_keeper_t* pkeeper = join_bucket_keeper_alloc_from_reader(preader, NULL, NULL, pleft_field_names);
	sllv_t* precords_paired;
	sllv_t* precords_left_unpaired;

	slls_t* pright_field_values = slls_single_no_free("1");
	emit(pkeeper, pright_field_values, &precords_paired, &precords_left_unpaired);
	mu_assert_lf(list_has_length(precords_paired, 2, "paired", pright_field_values->phead->value));
	mu_assert_lf(list_has_length(precords_left_unpaired, 2, "unpaired", pright_field_values->phead->value));
	printf("\n");

	emit(pkeeper, NULL, &precords_paired, &precords_left_unpaired);
	mu_assert_lf(list_is_null(precords_paired, "paired", "(eof)"));
	mu_assert_lf(list_has_length(precords_left_unpaired, 5, "unpaired", "(eof)"));

	printf("\n");
	printf("test_het_initial_pairing exit\n");
	printf("\n");
	return 0;
}
Пример #7
0
static void the_translate_method_sends_its_data_to_write_output(void **state) {
  set_up();

  translate();

  (void) state;
}
Пример #8
0
static void the_translate_method_gets_its_data_from_read_input(void **state) {
  set_up();

  translate();

  (void) state;
}
Пример #9
0
static void
empathy_groups_widget_init (EmpathyGroupsWidget *self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
      EMPATHY_TYPE_GROUPS_WIDGET, EmpathyGroupsWidgetPriv);

  set_up (self);
}
Пример #10
0
static void the_translate_method_returns_1_on_success(void **state) {
  set_up();

  int i = translate();

  assert_int_equal(i, 1);

  (void) state;
}
Пример #11
0
void Camera::init(glm::vec3 position,
				  glm::vec3 target, 
				  glm::vec3 up,
				  float speed)
{
	set_up(up);
	set_speed(speed);
	set_target(target);
	set_position(position);
	resetMouseToCenter();
	lookAt();
}
Пример #12
0
static void
empathy_individual_linker_init (EmpathyIndividualLinker *self)
{
  EmpathyIndividualLinkerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
      EMPATHY_TYPE_INDIVIDUAL_LINKER, EmpathyIndividualLinkerPriv);

  self->priv = priv;

  priv->changed_individuals = g_hash_table_new (NULL, NULL);

  set_up (self);
}
Пример #13
0
bool test_move() {
  bool result = true;
  
  piece p = new_piece(0, 0, 2, 1, true, false); //move_x-> TRUE, move_y->FALSE
  set_up();
  
  for (int dist = 1; dist < NB_PIECES; dist++)
    for (int i=0; i < NB_PIECES; i++) {

      // Test move LEFT
      copy_piece(pieces[i],p);
      move_piece(p, LEFT, dist);

      if (can_move_x(pieces[i]))
        result = result && test_equality_int(get_x(pieces[i])-dist,get_x(p),"move LEFT");
      else
        result = result && test_equality_int(get_x(pieces[i]),get_x(p),"move LEFT");

      // Test move RIGHT
      copy_piece(pieces[i],p);
      move_piece(p, RIGHT, dist);
      
      if (can_move_x(pieces[i]))
        result = result && test_equality_int(get_x(pieces[i])+dist,get_x(p),"move RIGHT");
      else
        result = result && test_equality_int(get_x(pieces[i]),get_x(p),"move RIGHT");

      // Test move UP
      copy_piece(pieces[i],p);
      move_piece(p, UP, dist);
      
      if (can_move_y(pieces[i]))
        result = result && test_equality_int(get_y(pieces[i])+dist,get_y(p),"move UP");
      else
        result = result && test_equality_int(get_y(pieces[i]),get_y(p),"move UP");

      // Test move DOWN
      copy_piece(pieces[i],p);
      move_piece(p, DOWN, dist);
      
      if (can_move_y(pieces[i]))
        result = result && test_equality_int(get_y(pieces[i])-dist,get_y(p),"move DOWN");
      else
        result = result && test_equality_int(get_y(pieces[i]),get_y(p),"move DOWN");

    }
  
  tear_down();
  delete_piece(p);
  
  return result;
}
Пример #14
0
void test_lpd8806_map_output_to_point_left_bottom(void) {
   set_up();

   int output = 29;
   int x = -1;
   int y = -1;
   int retval = ambitv_lpd8806_map_output_to_point(SINK, output, DISPLAY_WIDTH, DISPLAY_HEIGHT, &x, &y);
   CU_ASSERT_EQUAL(x, 0);
   CU_ASSERT_EQUAL(y, 100);
   CU_ASSERT_EQUAL(retval, 0);

   tear_down();
}
Пример #15
0
void test_lpd8806_map_output_to_point_second_led_on_the_right(void) {
   set_up();

   int output = 31;
   int x = -1;
   int y = -1;
   int retval = ambitv_lpd8806_map_output_to_point(SINK, output, DISPLAY_WIDTH, DISPLAY_HEIGHT, &x, &y);
   CU_ASSERT_EQUAL(x, 100);
   CU_ASSERT_EQUAL(y, 11);
   CU_ASSERT_EQUAL(retval, 0);

   tear_down();
}
Пример #16
0
int main()
{
	int c;
	set_up();

	while( ( c = getchar()) != 'Q'){
		if( c == 'f')	the_ball.x_ttm--;
		else if ( c == 's') the_ball.x_ttm++;
		else if ( c == 'F') the_ball.y_ttm--;
		else if ( c == 'S') the_ball.y_ttm++;
	}

	wrap_up();
}
Пример #17
0
void test_lpd8806_map_output_to_point_left_top(void) {
   set_up();

   // First LED on the third side means output: 20 ( 10 * (SIDE - 1) + (LED_IDX - 1) )
   int output = 20;
   int x = -1;
   int y = -1;
   int retval = ambitv_lpd8806_map_output_to_point(SINK, output, DISPLAY_WIDTH, DISPLAY_HEIGHT, &x, &y);
   CU_ASSERT_EQUAL(x, 0);
   CU_ASSERT_EQUAL(y, 0);
   CU_ASSERT_EQUAL(retval, 0);

   tear_down();
}
Пример #18
0
int main()
{
	int	c;

	set_up();

	while ( ( c = getchar()) != 'Q' ){
		if ( c == 'f' )	     the_ball.x_ttm--;
		else if ( c == 's' ) the_ball.x_ttm++;
		else if ( c == 'F' ) the_ball.y_ttm--;
		else if ( c == 'S' ) the_ball.y_ttm++;
	}

	endwin();		/* put back to normal	*/
}
Пример #19
0
int main()
{
    int c;

    set_up();
    while( (c = getch()) != 'Q' )
    {
        if( c == 'f' ) ball.x_ttm--;
        else if( c == 's' ) ball.x_ttm++;
        else if( c == 'F' ) ball.y_ttm--;
        else if( c == 'S' ) ball.y_ttm++;
    }
    wrap_up();

    return 0;
}
Пример #20
0
bool test_copy() {
  piece p = new_piece_rh(0, 0, true, true);
  bool result = true;
  set_up();
  for (int i = 0 ; i < NB_PIECES; i++) {
    copy_piece(pieces[i],p);
    result = result && test_equality_int(get_height(pieces[i]), get_height(p), "copy get_height");
    result = result && test_equality_int(get_width(pieces[i]), get_width(p), "copy get_width");
    result = result && test_equality_int(get_x(pieces[i]), get_x(p), "copy get_x");
    result = result && test_equality_int(get_y(pieces[i]), get_y(p), "copy get_y");
    result = result && test_equality_bool(is_horizontal(pieces[i]), is_horizontal(p), "copy is_horizontal");
  }
  tear_down();
  delete_piece(p);
  return result;
}
Пример #21
0
void test_lpd8806_map_output_to_point_one_pal(void)
{
   set_up();
   int DISPLAY_WIDTH_PAL = 702;
   int DISPLAY_HEIGHT_PAL = 576;

   int output = 1; 
   int x = -1;
   int y = -1;
   int retval = ambitv_lpd8806_map_output_to_point(SINK, output, DISPLAY_WIDTH_PAL, DISPLAY_HEIGHT_PAL, &x, &y);
   CU_ASSERT_EQUAL(x, 78);
   CU_ASSERT_EQUAL(y, 0);
   CU_ASSERT_EQUAL(retval, 0);

   tear_down();
}
Пример #22
0
static HEARTBEAT_TEST_FIXTURE set_up_dtls(const char *const test_case_name)
{
    HEARTBEAT_TEST_FIXTURE fixture = set_up(test_case_name,
                                            DTLSv1_server_method());
    fixture.process_heartbeat = dtls1_process_heartbeat;

    /*
     * As per dtls1_get_record(), skipping the following from the beginning
     * of the returned heartbeat message: type-1 byte; version-2 bytes;
     * sequence number-8 bytes; length-2 bytes And then skipping the 1-byte
     * type encoded by process_heartbeat for a total of 14 bytes, at which
     * point we can grab the length and the payload we seek.
     */
    fixture.return_payload_offset = 14;
    return fixture;
}
Пример #23
0
void test_lpd8806_map_output_to_point_top_second_last_with_inset(void)
{
   set_up();

   int output = 8; 
   int x = -1;
   int y = -1;
   double *inset = get_inset(SINK);
   inset[0] = -0.10;
   int retval = ambitv_lpd8806_map_output_to_point(SINK, output, DISPLAY_WIDTH, DISPLAY_HEIGHT, &x, &y);
   CU_ASSERT_EQUAL(x, 96);
   CU_ASSERT_EQUAL(y, 0);
   CU_ASSERT_EQUAL(retval, 0);

   tear_down();
}
Пример #24
0
void test_lpd8806_ptr_for_output_top_left(void)
{
   set_up();

   int output = 0;
   int str_idx = -1;
   int led_idx = -1;

   int *ptr = ambitv_lpd8806_ptr_for_output(SINK->priv, output, &str_idx, &led_idx);
   CU_ASSERT_EQUAL(str_idx, 0);
   CU_ASSERT_EQUAL(led_idx, 0);
   CU_ASSERT_PTR_NOT_NULL_FATAL(ptr);
   CU_ASSERT_EQUAL(ptr, get_led_str(SINK, 0, 0));

   tear_down();
}
Пример #25
0
int main(int argc, char* argv[]) {
  vector<double> ind;
  int n = 0;
  int m = 0;
  set_up(argc, argv, ind, n, m);
  std::cout << "num_dep = " << m << ", num_ind = " << n << std::endl;
  adouble* xad = new adouble[n];
  adouble* yad = new adouble[m];
  double* y = new double[m];
  double* x = new double[n];

  for (int i = 0; i < n; i++) {
    x[i] = ind[i];
  }
  trace_on(TAG);
  for (int i = 0; i < n; i++) {
    xad[i] <<= x[i];
  }
  func_eval<adouble>(n, xad, m, yad);
#ifdef DUMMY_SCALAR
  adouble zad = 0;
  double z;
  for (int i = 0; i < m; i++) {
    zad = zad + yad[i];
  }
  zad >>= z;
  std::cout << "func_eval = " << z << std::endl;
  m = 1;
#else
  for (int i = 0; i < m; i++) {
    yad[i] >>= y[i];
    //std::cout << "y["<<i<<"] = " << y[i] << std::endl;
  }
#endif
  trace_off(); 

  tear_down();
  // Evaluate derivatives;
  int options[2] = {ORDER, METHOD};
  double t;
  std::cout << "m = " << m << " n = " << n << std::endl;
  t = evaluate_derivatives(n, m, x, options);

  delete[] xad;
  delete[] yad;

}
Пример #26
0
bool test_intersect() {
  bool result = true;
  set_up();
  for (int i=0; i < NB_PIECES; i++)
    for (int j =0; j<NB_PIECES; j++) {
      result = result && test_equality_bool(i==j, intersect(pieces[i], pieces[j]),"intersect");
    }

  piece pb_piece1 = new_piece_rh(3, 3, false, false);
  piece pb_piece2 = new_piece_rh(3, 1, false, false);
  result = result && test_equality_bool(true, intersect(pieces[0], pb_piece1),"intersect pb1");
  result = result && test_equality_bool(true, intersect(pb_piece2, pb_piece1),"intersect pb2");
  tear_down();
  delete_piece(pb_piece1);
  delete_piece(pb_piece2);
  return result;
}
Пример #27
0
static HEARTBEAT_TEST_FIXTURE set_up_tls(const char *const test_case_name)
{
    HEARTBEAT_TEST_FIXTURE fixture = set_up(test_case_name,
                                            TLSv1_server_method());
    fixture.process_heartbeat = tls1_process_heartbeat;
    fixture.s->handshake_func = dummy_handshake;

    /*
     * As per do_ssl3_write(), skipping the following from the beginning of
     * the returned heartbeat message: type-1 byte; version-2 bytes; length-2
     * bytes And then skipping the 1-byte type encoded by process_heartbeat
     * for a total of 6 bytes, at which point we can grab the length and the
     * payload we seek.
     */
    fixture.return_payload_offset = 6;
    return fixture;
}
Пример #28
0
int main(int argc, char *argv[])
{
	gtk_init (&argc, &argv);

	GtkBuilder *builder;
	GError* error = NULL;

	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (builder, "/usr/local/share/iDeviceActivator/res/ui.xml", &error))
	{
		g_warning ("Couldn't load builder file: %s", error->message);
		g_error_free (error);
	}

	gtk_builder_connect_signals (builder, NULL);
	window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
	button=GTK_WIDGET(gtk_builder_get_object(builder, "uBut"));
	button1=GTK_WIDGET(gtk_builder_get_object(builder, "button1"));
	devImg=GTK_WIDGET(gtk_builder_get_object(builder, "devImg"));
	dName=GTK_WIDGET(gtk_builder_get_object(builder, "dName"));
	fV=GTK_WIDGET(gtk_builder_get_object(builder, "fV"));
	pL=GTK_WIDGET(gtk_builder_get_object(builder, "pL"));
	mmle_check=GTK_WIDGET(gtk_builder_get_object(builder, "make_my_life_easier"));

	g_signal_connect (G_OBJECT (button), "released",
		      G_CALLBACK (activate), NULL);
	g_signal_connect (G_OBJECT (button1), "released",
		      G_CALLBACK (deactivate), NULL);
        g_signal_connect (G_OBJECT (window), "destroy",
		      G_CALLBACK (destroy), NULL);

	set_up();

	read_in_plists();

	fill_in_info();

	g_object_unref (builder);

	gtk_widget_show (window);

	gtk_main ();

	return 0;
}
Пример #29
0
int main(void) {
  set_up();

  int c;
  while ((c = getch()) != 'Q') {
    if (c == 'f') the_ball.x_ttm--;
    if (c == 's') the_ball.x_ttm++;
    if (c == 'F') the_ball.y_ttm--;
    if (c == 'S') the_ball.y_ttm++;
    
    if (c == 'j' && the_bar.bottom_y != BOTTOM_EDGE) 
      the_bar.dir = BAR_DOWN;
    if (c == 'k' && the_bar.top_y != TOP_EDGE)
      the_bar.dir = BAR_UP;
  }

  end_down();
  return EXIT_SUCCESS;
}
Пример #30
0
int main()
{

	if (set_up() < 0) {
		print_error("Test set_up() error");
		goto error;
	}

	if (test_signature() < 0) {
		goto error;
	}

	tear_down();

	return 0;

error:
	return EXIT_FAILURE;
}