예제 #1
0
static void
objects_added (EBookClientView *view,
               const GSList *contacts,
               gpointer user_data)
{
	const GSList *l;
	GMainLoop *loop = (GMainLoop *) user_data;

	for (l = contacts; l; l = l->next) {
		EContact *contact = l->data;

#if !COMPARE_PERFORMANCE
		print_contact (contact);
#endif

		if (uids_only && e_contact_get_const (contact, E_CONTACT_FULL_NAME) != NULL)
			g_error (
				"received contact name `%s' when only the uid was requested",
				(gchar *) e_contact_get_const (contact, E_CONTACT_FULL_NAME));
		else if (!uids_only && e_contact_get_const (contact, E_CONTACT_FULL_NAME) == NULL)
			g_error ("expected contact name missing");
	}

	if (!loading_view)
		finish_test (view, loop);

}
예제 #2
0
int main(int argc, char *argv[])
{
    int ret;
    setup_test();

    ret = test_main(argc, argv);

    return finish_test(ret);
}
예제 #3
0
파일: test_load.c 프로젝트: masonsbro/HMM
int main(int argc, char* argv[]) {

    int expected_num_states = 5;
    int expected_num_tokens = 20;
    int expected_distr_total[5] = {100, 100, 100, 100, 100};
    int expected_distr[5][6] = {{0, 50, 40, 0, 10, 0},
                                {0, 0, 0, 95, 5, 0},
                                {0, 10, 0, 0, 80, 10},
                                {0, 5, 0, 0, 85, 10},
                                {0, 25, 25, 0, 0, 50}};
    char* expected_tokens[20] = {"the", "a", "that", "Tom", "John", "Mary",
                                 "Alice", "Jerry", "cat", "dog", "car", "pen",
                                 "bed", "apple", "bit", "ate", "saw", "played",
                                 "hit", "gave"};
    int expected_token_distr_total[5] = {0, 8, 5, 6, 6};
    int expected_token_distr[5][20] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                                       {4, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                                       {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                                       {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
                                       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}};

    HMM* hmm = malloc(sizeof(HMM));
    FILE* stream = fopen("test/hmm_1", "r");
    load_HMM(stream, hmm);
    fclose(stream);

    set_test_name(argv[0]);

    assert_int_e(expected_num_states, hmm->num_states);
    assert_int_e(expected_num_tokens, hmm->num_tokens);

    assert_inta_e(expected_distr_total, hmm->state_distribution_total, 5);

    assert_inta_e(expected_distr[0], hmm->state_distribution[0], 6);
    assert_inta_e(expected_distr[1], hmm->state_distribution[1], 6);
    assert_inta_e(expected_distr[2], hmm->state_distribution[2], 6);
    assert_inta_e(expected_distr[3], hmm->state_distribution[3], 6);
    assert_inta_e(expected_distr[4], hmm->state_distribution[4], 6);

    assert_stra_e(expected_tokens, hmm->tokens, 20);

    assert_inta_e(expected_token_distr_total, hmm->token_distribution_total, 5);

    assert_inta_e(expected_token_distr[0], hmm->token_distribution[0], 20);
    assert_inta_e(expected_token_distr[1], hmm->token_distribution[1], 20);
    assert_inta_e(expected_token_distr[2], hmm->token_distribution[2], 20);
    assert_inta_e(expected_token_distr[3], hmm->token_distribution[3], 20);
    assert_inta_e(expected_token_distr[4], hmm->token_distribution[4], 20);

    finish_test();

    return 0;

}
예제 #4
0
파일: main.cpp 프로젝트: HackLinux/MESI-1
int main(int argc, char *argv[]) {
  int cycle;

  parse_args(argc, argv);
  init_system();
  
  for (cycle = 0; cycle < args.num_cycles; ++cycle) {
    advance_time();
  }

  for (int i = 0; i < args.num_procs; ++i) {
    caches[i]->print_stats();
    ius[i]->print_stats();
  }

  finish_test();
  
}
static void
objects_added (EBookClientView *view,
               const GSList *contacts)
{
	const GSList *l;

	for (l = contacts; l; l = l->next) {
		EContact *contact = l->data;

		print_contact (contact);

		if (e_contact_get_const (contact, E_CONTACT_FULL_NAME) != NULL)
			g_error ("received contact name `%s' when only the uid and revision was requested",
				 (gchar *) e_contact_get_const (contact, E_CONTACT_FULL_NAME));
	}

	if (!loading_view)
		finish_test (view);

}
static void
objects_added (EBookClientView *view,
               const GSList *contacts,
               gpointer user_data)
{
	const GSList *l;
	GMainLoop *loop = (GMainLoop *) user_data;

	/* We quit the mainloop and the test succeeds if we get the notification
	 * for the contact we add after loading the view completes */
	for (l = contacts; l; l = l->next) {
		print_email (l->data);
	}

	if (loading_view)
		g_error ("Expected no contact additions while loading the view");
	else {
		finish_test (view, loop);
	}

}
예제 #7
0
int main(int argc, char* argv[]) {

    set_test_name(argv[0]);

    char string1[] = "hi";
    int expected1 = 'h' + 'i' * 3;

    assert_int_e(expected1, ht_hash_string(string1));

    char string2[] = "08/";
    int expected2 = '0' + '8' * 3 + '/' * 9;

    assert_int_e(expected2, ht_hash_string(string2));

    char string3[] = "kh";
    int expected3 = expected1;

    assert_int_e(expected3, ht_hash_string(string3));

    finish_test();

    return 0;

}
예제 #8
0
int main(int argc, char* argv[]) {

    set_test_name(argv[0]);

    HMM* hmm = malloc(sizeof(*hmm));
    hmm->num_states = 3;
    hmm->num_tokens = 2;
    hmm->state_distribution_total = malloc(3 * sizeof(*hmm->state_distribution_total));
    hmm->state_distribution = malloc(3 * sizeof(*hmm->state_distribution));
    hmm->tokens = malloc(2 * sizeof(*hmm->tokens));
    hmm->token_distribution_total = malloc(3 * sizeof(*hmm->token_distribution_total));
    hmm->token_distribution = malloc(3 * sizeof(*hmm->token_distribution));

    hmm->state_distribution_total[0] = 1;
    hmm->state_distribution_total[1] = 1;
    hmm->state_distribution_total[2] = 1;

    hmm->state_distribution[0] = malloc(4 * sizeof(*hmm->state_distribution[0]));
    hmm->state_distribution[0][0] = 0;
    hmm->state_distribution[0][1] = 1;
    hmm->state_distribution[0][2] = 0;
    hmm->state_distribution[0][3] = 0;

    hmm->state_distribution[1] = malloc(4 * sizeof(*hmm->state_distribution[1]));
    hmm->state_distribution[1][0] = 0;
    hmm->state_distribution[1][1] = 0;
    hmm->state_distribution[1][2] = 1;
    hmm->state_distribution[1][3] = 0;

    hmm->state_distribution[2] = malloc(4 * sizeof(*hmm->state_distribution[2]));
    hmm->state_distribution[2][0] = 0;
    hmm->state_distribution[2][1] = 0;
    hmm->state_distribution[2][2] = 0;
    hmm->state_distribution[2][3] = 1;

    hmm->tokens[0] = "a";
    hmm->tokens[1] = "the";

    hmm->token_distribution_total[0] = 0;
    hmm->token_distribution_total[1] = 1;
    hmm->token_distribution_total[2] = 1;

    hmm->token_distribution[0] = malloc(2 * sizeof(*hmm->token_distribution[0]));
    hmm->token_distribution[0][0] = 0;
    hmm->token_distribution[0][1] = 0;

    hmm->token_distribution[1] = malloc(2 * sizeof(*hmm->token_distribution[1]));
    hmm->token_distribution[1][0] = 1;
    hmm->token_distribution[1][1] = 0;

    hmm->token_distribution[2] = malloc(2 * sizeof(*hmm->token_distribution[2]));
    hmm->token_distribution[2][0] = 0;
    hmm->token_distribution[2][1] = 1;

    int expected_length = 2;
    char** expected_sequence = malloc(2 * sizeof(*expected_sequence));
    expected_sequence[0] = "a";
    expected_sequence[1] = "the";

    char** actual_sequence = malloc(5 * sizeof(*actual_sequence));

    // Test generating full-length (nonbinding max_length)
    assert_int_e(expected_length, generate_sequence(hmm, actual_sequence, 5));
    assert_stra_e(expected_sequence, actual_sequence, expected_length);

    expected_length = 1;
    expected_sequence[0] = "a";
    expected_sequence[1] = NULL;
    actual_sequence[0] = NULL;
    actual_sequence[1] = NULL;

    // Test binding max_length
    assert_int_e(expected_length, generate_sequence(hmm, actual_sequence, 1));
    assert_stra_e(expected_sequence, actual_sequence, expected_length);

    finish_test();

    return 0;

}
예제 #9
0
파일: test.c 프로젝트: npic/rtvmc
errcode_t test_step(test_t * test)
{
    errcode_t retval;
    uint16_t i;
    uint8_t pin_val;
    /*
    char uart_out_char = 0;
    */
    retval = reschedule(&test->uut);
    CHECK_OK(retval, "Failed to do scheduling\n");
    test->uut.PP = test->uut.NPP;
    for (i = 0; i < test->uut.proc_table_size; i++)
    {
        if (test->uut.PP == i)
        {
            fprintf(test->schedules[i], "%u 1\n", test->uut.time);
        }
        else
        {
            fprintf(test->schedules[i], "%u 0\n", test->uut.time);
        }
    }
    for (i = 0; i < test->input_size; i++)
    {
        if (test->gpio_input[i].time == test->uut.time)
        {
            retval = gpio_set(test->gpio_input[i].pin, test->gpio_input[i].value);
            CHECK_OK(retval, "Failed to set test pin\n");
        }
        /*
        if (test->timings[i] == test->uut.time)
        {
            retval = enqueue(&test->uut.uart.in, test->input[i]);
            CHECK_OK(retval, "Failed to enqueue a test input\n");
            fprintf(test->uart_in, "%hu %hd\n", test->uut.time, (int16_t)test->input[i]);
            CHECK_NOT_FERROR(test->uart_in);
            break;
        }
        */
    }
    for (i = 0; i < TEST_PIN_COUNT; i++)
    {
        retval = gpio_get(i, &pin_val);
        CHECK_OK(retval, "Failed to get test pin\n");
        fprintf(test->gpio_files[i], "%u %u\n", test->uut.time, pin_val);
    }
    /*
    if (i == test->input_size)  / * i.e. there is no input this time * /
    {
        fprintf(test->uart_in, "%hu 0\n", test->uut.time);
        CHECK_NOT_FERROR(test->uart_in);
    }
    retval = dequeue(&test->uut.uart.out, &uart_out_char);
    CHECK_OK(retval, "Failed to dequeue from UART out\n");
    fprintf(test->uart_out, "%hu %hd\n", test->uut.time, (int16_t)uart_out_char);
    CHECK_NOT_FERROR(test->uart_out);
    */
    test->uut.proc_table[test->uut.PP].current_observed_time++;
    retval = step(&test->uut);
    test->uut.time++;
    CHECK_OK(retval, "Failed to execute instruction\n");
    if (test->uut.time >= test->test_length)
    {
        finish_test(test);
    }
    return OK;
}