summaryrefslogtreecommitdiffstats
path: root/util/test/rand/rand_test.c
blob: 90c566b284e041e651b7649da9498018214c119a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "../util/create_env.h"

/** @brief test_rand 
 *   create random variable and get it's value 
 */

axis2_status_t test_rand(axutil_env_t *env)
{    
    int rand_number,rand_value,start = 2,end = 8,rand_range;
    unsigned seed = 10;
    
    rand_number = axutil_rand(&seed);
    if(!rand_number)
    {
        printf("Test axutil_rand failed\n");         
    }
    else
    {
        printf("Test axutil_rand is successfull\n");
        printf("The random value is %d\n",rand_number);
    }
    
    rand_range = axutil_rand_with_range(&seed,start,end);
    if(rand_range == -1)
    {
        printf("Test axutil_rand_with_range failed\n");
    }
    else
    {
        printf("Test axutil_rand_with_range is successfull\n");
        printf("The random seed value is %d\n",rand_range);
    }
    
    rand_value = axutil_rand_get_seed_value_based_on_time(env);
    if(!rand_value)
    {
        printf("The test axutil_rand_get_seed_value_based_on_time failed\n");
    }
    else
    {
        printf("Test axutil_rand_get_seed_value_based_on_time is successfull\n");
        printf("The random range is %d\n",rand_value);
    }
 
    return AXIS2_SUCCESS;
}

int main()
{
    int status = AXIS2_SUCCESS;
    axutil_env_t *env = NULL;

    env = create_environment();
    status = test_rand(env);

    if(status == AXIS2_FAILURE)
    {
        printf("Test  failed\n");
    }
    axutil_env_free(env);
    return 0;
}