summaryrefslogtreecommitdiffstats
path: root/util/test/rand
diff options
context:
space:
mode:
authorGravatar damitha2010-07-08 06:38:10 +0000
committerGravatar damitha2010-07-08 06:38:10 +0000
commitc8d5aeb5d3048e8a037f1884b59cef8adf7e25b2 (patch)
tree6edd50a5f63708b4c916614809082d9c1090b262 /util/test/rand
parent4a01960cba446e046d5687279c024fa60b576d85 (diff)
downloadaxis2c-c8d5aeb5d3048e8a037f1884b59cef8adf7e25b2.tar.gz
axis2c-c8d5aeb5d3048e8a037f1884b59cef8adf7e25b2.tar.bz2
Added the simple test suite suggested in AXIS2C-1412
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@961590 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util/test/rand')
-rw-r--r--util/test/rand/Makefile.am4
-rw-r--r--util/test/rand/rand_test.c64
2 files changed, 25 insertions, 43 deletions
diff --git a/util/test/rand/Makefile.am b/util/test/rand/Makefile.am
index 6c75e30..49c2f48 100644
--- a/util/test/rand/Makefile.am
+++ b/util/test/rand/Makefile.am
@@ -7,7 +7,9 @@ rand_test_LDADD = \
$(top_builddir)/src/libaxutil.la
INCLUDES = -I$(top_builddir)/include \
+ -I$(CUTEST_HOME)/include \
-I ../../../axiom/include \
- -I ../../../include
+ -I ../../../include \
+ -I ../../../cutest/include
diff --git a/util/test/rand/rand_test.c b/util/test/rand/rand_test.c
index 90c566b..71dc232 100644
--- a/util/test/rand/rand_test.c
+++ b/util/test/rand/rand_test.c
@@ -1,63 +1,43 @@
#include "../util/create_env.h"
+#include <axutil_rand.h>
+#include <cut_defs.h>
/** @brief test_rand
* create random variable and get it's value
*/
-axis2_status_t test_rand(axutil_env_t *env)
+void 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);
- }
-
+ printf("rand_number : %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);
- }
-
+ printf("rand_range : %d\n", rand_range);
+ CUT_ASSERT(rand_range != -1);
+ CUT_ASSERT(rand_range >= start && rand_range <= end);
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;
+ printf("rand_based_on_time : %d\n", rand_value);
+
+ /* To avoid warning of not using cut_ptr_equal */
+ CUT_ASSERT_PTR_EQUAL(NULL, NULL, 0);
+ /* To avoid warning of not using cut_int_equal */
+ CUT_ASSERT_INT_EQUAL(0, 0, 0);
+ /* To avoid warning of not using cut_str_equal */
+ CUT_ASSERT_STR_EQUAL("", "", 0);
+
}
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_t *env = cut_setup_env("Rand");
+ CUT_ASSERT(env != NULL);
+ if (env) {
+ test_rand(env);
+ axutil_env_free(env);
}
- axutil_env_free(env);
+ CUT_RETURN_ON_FAILURE(-1);
return 0;
}