Example #1
0
File: main.c Project: phylolvb/lvb
int main(void)
{
    char *s1;	/* test string */
    char *s3;	/* test string */
    long i;	/* loop counter */
    long j;	/* loop counter */

    lvb_initialize();

    for (i = 0; i < 50000; i++)	/* repeat to check heap seems OK */
    {
	s1 = alloc(S1_LENGTH + 1, "test string s1");
	for (j = 0; j < S1_LENGTH; j++) s1[j] = '@';
	s1[S1_LENGTH] = 0;
	lvb_assert(strcmp(s1, s2) == 0);
	s3 = alloc(strlen(s1)+1, "test string s3");
	strcpy(s3, s1);
	free(s1);
	lvb_assert(strcmp(s3, s2) == 0);
	free(s3);
    }

    printf("test passed\n");
    return 0;
}
Example #2
0
File: main.c Project: phylolvb/lvb
int main(void)
{
    long m;				/* sites */
    long n;				/* sequences */
    int max_length_name;		/* mas name length */
    Lvb_bool success = LVB_FALSE;	/* test passed */
    Params rcstruct;		/* configurable parameters */

    lvb_initialize();

//    rcstruct.file_name_in = "infile";
    strcpy(rcstruct.file_name_in, "infile");
    rcstruct.n_file_format = FORMAT_PHYLIP;

    phylip_mat_dims_in(rcstruct.file_name_in, rcstruct.n_file_format, &n, &m, &max_length_name);
    if ((n == EXPECTED_N) && (m == EXPECTED_M))
    {
    	/* try it again and check it still works */
	phylip_mat_dims_in(rcstruct.file_name_in, rcstruct.n_file_format, &n, &m, &max_length_name);
	if ((n == EXPECTED_N) && (m == EXPECTED_M))
	    success = LVB_TRUE;
    }

    if (success == LVB_TRUE)
        printf("test passed\n");
    else
    	printf("test failed\n");

    return 0;
}
Example #3
0
int main(void)
{
    lvb_initialize();

    scream("%d %d %d %d %d %d %d %s!", 1, 2, 3, 4, 5, 6, 7,
    "TEST%STRING%GOES%d%d%dHERE");
    printf("returned!\n");
    return 0;
}
Example #4
0
File: main.c Project: phylolvb/lvb
int main(int argc, char **argv)
{
    long i = 32447881;

	MPI_Init(&argc, &argv);
    lvb_initialize();

    crash("%ld is causing trouble", i);

    /* if we reach here, crash() isn't working */
    printf("test failed\n");
    return 0;	/* program success indicates crash()'s failure */
}
Example #5
0
File: main.c Project: phylolvb/lvb
int main(int argc, char **argv)
{
	MPI_Init(&argc, &argv);
    lvb_initialize();

    log_wrapper(-1);	/* should cause domain error */

    /* if we get this far, log_wrapper() has failed to crash so the
     * test has failed */
    printf("test failed\n");

    exit(EXIT_SUCCESS);	/* we want failure: so program success
                         * indicates test failed */
}
Example #6
0
int main(void)
{
    const char *p1 = "";
    const char *p2 = "\b\a!\"$%^&*()_+NO_SPACE+IN$HERE!@#~'";
    const char *p3 = "\v\t\r\n \f\aHello Goodbye \n";

    lvb_initialize();

    lvb_assert(nextnonwspc(p1) == NULL);
    lvb_assert(nextnonwspc(p2) == p2);
    lvb_assert(nextnonwspc(p3) == p3 + 6);

    printf("test passed\n");
    return 0;
}
Example #7
0
int main(void)
{
    size_t i;	/* loop counter */

    lvb_initialize();
    p = alloc(ALLOCATION, "massive array");

    /* It is likely we do not reach this stage. If we have, check that
     * the allocation really did succeed, by writing to the whole
     * array, freeing it, and testing allocation of a smaller array. */
    for (i = 0; i < ALLOCATION; i++)
    	p[i] = ' ';
    free(p);
    small_p = alloc(SMALL_ALLOCATION * sizeof(double), "second array");
    for (i = 0; i < SMALL_ALLOCATION; i++)
        small_p[i] = DBL_MAX;
    free(small_p);

    printf("test passed\n");
    return EXIT_SUCCESS;
}
Example #8
0
int main(void)
{
    long i;				/* loop counter */
    long rand_val;			/* random number */
    long first_rand_val;		/* first random number */
    time_t tim;				/* system time */
    unsigned long ul_seed;		/* seed, from system time */
    Lvb_bool all_same = LVB_TRUE;	/* all 'random' values same */

    lvb_initialize();

    /* seed random number generator from system clock */
    tim = time(NULL);
    lvb_assert(tim != -1);
    ul_seed = (unsigned long) tim;
    ul_seed = ul_seed % (1UL + (unsigned long) MAX_SEED);
    lvb_assert(ul_seed <= MAX_SEED);
    rinit((int) ul_seed);
 
    first_rand_val = randpint(UPPER_LIM);
    for (i = 0; i < LOOP_CNT; i++)
    {
        rand_val = randpint(UPPER_LIM);
	lvb_assert(rand_val <= UPPER_LIM);
	lvb_assert(rand_val >= 0);
	if (rand_val != first_rand_val)
	    all_same = LVB_FALSE;
    }

    if (all_same == LVB_FALSE)
    {
        printf("test passed\n");
	return EXIT_SUCCESS;
    }
    else
    {
        printf("test failed\n");
	return EXIT_FAILURE;
    }
}
Example #9
0
File: main.c Project: phylolvb/lvb
int main(void)
{
    /* strings that are the same, considered case-insensitively */
    static char s1[] = "`1234567890-=!\"$%^&*("
     ")_+qwertyuiopasdfghjklzxcvbnm[]{};'#:@~,./<>? \t\n\r";
    static char s2[] = "`1234567890-=!\"$%^&*("
     ")_+QWERTYUIOPASDFGHJKLZXCVBNM[]{};'#:@~,./<>? \t\n\r";

    /* string that is almost the same but actually different */
    static char s3[] = "`1234567890-=!\"$%^&*("
     ")_+QWERTYUIOPASDFGHJKLZXCVBNN[]{};'#:@~,./<>? \t\n\r";

    lvb_initialize();

    lvb_assert(cistrcmp(s1, s1) == 0);
    lvb_assert(cistrcmp(s3 + 5, s3) != 0);
    lvb_assert(cistrcmp(s1, s2) == 0);
    lvb_assert(cistrcmp(s2, s3) != 0);

    printf("test passed\n");
    return 0;
}