summaryrefslogtreecommitdiffstats
path: root/util/test/rand
diff options
context:
space:
mode:
authorGravatar gmcdonald2010-02-13 01:32:03 +0000
committerGravatar gmcdonald2010-02-13 01:32:03 +0000
commit0425aadc78680e53000fd0108b540d6eca048516 (patch)
tree8ec7ab8e015d454c5ec586dfc91e05a2dce1cfc0 /util/test/rand
downloadaxis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.gz
axis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.bz2
Moving axis svn, part of TLP move INFRA-2441
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util/test/rand')
-rw-r--r--util/test/rand/Makefile.am13
-rw-r--r--util/test/rand/build.sh3
-rw-r--r--util/test/rand/rand_test.c64
3 files changed, 80 insertions, 0 deletions
diff --git a/util/test/rand/Makefile.am b/util/test/rand/Makefile.am
new file mode 100644
index 0000000..6c75e30
--- /dev/null
+++ b/util/test/rand/Makefile.am
@@ -0,0 +1,13 @@
+TESTS = rand_test
+check_PROGRAMS = rand_test
+noinst_PROGRAMS = rand_test
+rand_test_SOURCES = rand_test.c ../util/create_env.c
+
+rand_test_LDADD = \
+ $(top_builddir)/src/libaxutil.la
+
+INCLUDES = -I$(top_builddir)/include \
+ -I ../../../axiom/include \
+ -I ../../../include
+
+
diff --git a/util/test/rand/build.sh b/util/test/rand/build.sh
new file mode 100644
index 0000000..ee98324
--- /dev/null
+++ b/util/test/rand/build.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+gcc rand_test.c ../util/create_env.c -g -Werror -I$AXIS2C_HOME/include/axis2-1.3.0 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -o rand_test -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib
diff --git a/util/test/rand/rand_test.c b/util/test/rand/rand_test.c
new file mode 100644
index 0000000..90c566b
--- /dev/null
+++ b/util/test/rand/rand_test.c
@@ -0,0 +1,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;
+}
+
+