Hi,
I have correct some mistakes in date time test and added some small things.
Here I have attached the my version of date time test. It's better if you
can analyze it and comment on the implementation. Then we can identify
proper way to write test cases for current utility implementations. Also I
think it's better if we create a wiki page to track the progress of these
test cases. Then anyone can contribute to design of these test cases.

Thanks
Milinda

On Feb 5, 2008 2:13 PM, Dushshantha Chandradasa <
[EMAIL PROTECTED]> wrote:

> Hi Milinda and All,
>
> Thank you very much for your valuable comment.  The main intension  behind
> writing these unit  test cases is to improve the the test coverage of our
> code base. Its really important to have unit tests not only to increase the
> code coverage percentage, but also to keep the code bug free. Since we
> didn't maintain a good set of unit tests from the  beginning , Manoj is
> helping us writing few test cases beginning from the areas that we never had
> unit tests before.
>
> Writing unit test cases for existing code written by somebody else is bit
> difficult. The good practice here is writing those while the developer
> writing the code. So I suggest  all of  us  that  we'll polish the new test
> cases up, to do a better job and make a habit of adding few unit tests for
> the changes you are doing to code. These good practices help us to keep our
> code in a high quality.
>
> Thanks,
> Dushshantha
>
>
>
> On Feb 4, 2008 9:13 PM, Milinda Pathirage <[EMAIL PROTECTED]>
> wrote:
>
> > Hi all,
> >
> > First of all I have to say that it's a good idea (tests for utils). I
> > analyze some of the test cases and found out that they were not correctly
> > implemented according to my knowledge. I think we have to figure out why we
> > need those test cases and what we are going to test using that test cases.
> > Looking at these implementations, I think no one can get any idea what they
> > are stands for (but the name says what is going to test). So, I think we
> > have to first identify what are we going to test and how we going to test
> > them . Then we can clearly design some test case that correctly check our
> > implementations for correctness. Followings things are some mistakes I found
> > out in implementations under allocator test, and date time test. I didn't
> > look into much about other tests but I think they also have same problems.
> >
> > When I first look at directory called allocator, I think it contains
> > test cases for our env->allocator. But what is inside is test for fread and
> > fwrite functions and function called test_base64() which contains some
> > axutil_base64_binary_t creation function calls and getter and setter methods
> > of it. Also some unwanted usage of global variables. Also axutil_env_t
> > structure creations are wrong. One axutil_env_creation is inside the main
> > method. It assigned created environment to global variable called env and
> > inside function implementation another environment creation function is
> > called and again assigned the return value to the same global variable.
> >
> > Inside date time test some mistakes that I have mentioned above also
> > visible and the date time string use to test has wrong format.
> > axis2_char_t * date_time_str = "2000-11-11 12:30:24";
> > I don't know whether it was used intentionally. But it must have
> > following format.
> > "2002-11-11T12:30:24"
> >
> > So I think we have to look at these tests seriously and design these
> > tests to test what we exactly want to test. Please feel free to comment on
> > this.
> >
> > Thanks
> >
> > Milinda
> >
> >
> >
> > --
> > http://inf-dimensions.blogspot.com "Infinite Dimensions"
> > http://think2ed.blogspot.com "thinksquared"
> > http://wsaxc.blogspot.com "Web Services With Axis2/C"
>
>
>


-- 
http://think2ed.blogspot.com "thinksquared"
http://wsaxc.blogspot.com "Web Services With Axis2/C"
#include <axutil_date_time.h>
#include <time.h>
#include <axutil_date_time_util.h>
#include <stdio.h>
#include <axutil_env.h>
#include "../util/create_env.h"

/** @brief test_rand 
 *   deserialize and serialize the time 
 */

axis2_status_t test_date_time(axutil_env_t *env)
{
    axutil_date_time_t *date_time = NULL;
    axutil_date_time_t *ref = NULL;
    axutil_date_time_t *date_time_offset = NULL;
    axis2_char_t *time_str = "22:45:12";
    axis2_char_t *date_str = "2000-12-12";
    axis2_char_t *date_time_str = "2000-11-11T12:30:24";
    axis2_status_t status = AXIS2_FAILURE;
    axutil_date_time_comp_result_t compare_res = AXIS2_DATE_TIME_COMP_RES_FAILURE;
    axis2_char_t *t_str = NULL, *d_str = NULL, *dt_str = NULL;
    int year , month , date , hour , min , sec , msec;
    
    date_time_offset = axutil_date_time_create_with_offset(env, 100);
    if(!date_time_offset)
    {
        printf("axutil_date_time_t creation failed.\n");
        return AXIS2_FAILURE;
    }
    date_time = axutil_date_time_create(env);
    if(!date_time)
    {
        printf("axutil_date_time_t creation failed.\n");
        return AXIS2_FAILURE;
    }
    status = axutil_date_time_deserialize_time(date_time, env, time_str);
    if(status)
        printf("axutil_date_time_t time string deserialization success.\n");
    status = axutil_date_time_deserialize_date(date_time, env, date_str);
    if(status)
        printf("axutil_date_time_t date string deserialization success.\n");
    status = axutil_date_time_deserialize_date_time(date_time, env, date_time_str);
    if(status)
        printf("axutil_date_time_t date time string deserialization success.\n");
    
    ref = axutil_date_time_create(env);
    if(!ref)
    {
        printf("axutil_date_time_t creation failed.\n");
        return AXIS2_FAILURE;
    }
    compare_res = axutil_date_time_compare(date_time, env, ref);
    if(compare_res == AXIS2_DATE_TIME_COMP_RES_FAILURE)
    {
        printf("axutil_date_time comparison failed.\n");
    }
    
    status = axutil_date_time_deserialize_date_time(ref, env, date_time_str);
    if(status)
        printf("axutil_date_time_t date time string deserialization success.\n");
    compare_res = axutil_date_time_compare(date_time, env, ref);
    if(compare_res == AXIS2_DATE_TIME_COMP_RES_EQUAL)
    {
        printf("axutil_date_time_t comparison success.");
    }
    status = axutil_date_time_set_date_time(date_time, env, 2008, 1, 8, 12, 18, 57, 799);
    if(status)
    {
        printf("axutil_date_time_t set date time success.\n");
    }
    
    t_str = axutil_date_time_serialize_time(date_time, env);
    if(!t_str)
    {
        printf("axutil_date_time_t time serialization failed.\n");
    }
    else
    {
        printf("axutil_date_time_t Time: %s\n", t_str);
    }
    d_str = axutil_date_time_serialize_date(date_time, env);
    if(!d_str)
    {
        printf("axutil_date_time_t date serialization failed.\n");
    }
    else
    {
        printf("axutil_date_time_t Date: %s\n", d_str);
    }
    dt_str = axutil_date_time_serialize_date_time(date_time, env);
    if(!dt_str)
    {
        printf("axutil_date_time_t date time serialization failed.\n");
    }
    else
    {
        printf("axutil_date_time_t Date Time: %s\n", dt_str);
    }
    year = axutil_date_time_get_year(date_time,env);
    month=axutil_date_time_get_month(date_time,env);
    date = axutil_date_time_get_date(date_time,env);
    hour = axutil_date_time_get_hour(date_time,env);
    min  = axutil_date_time_get_minute(date_time,env);
    sec  = axutil_date_time_get_second(date_time,env);
    msec = axutil_date_time_get_msec(date_time,env);
    printf("axutil_date_time_t year: %d \n",year);
    printf("axutil_date_time_t month: %d \n",month);
    printf("axutil_date_time_t date: %d \n",date);
    printf("axutil_date_time_t hour: %d \n",hour);
    printf("axutil_date_time_t min: %d \n",min);
    printf("axutil_date_time_t sec: %d \n",sec);
    printf("axutil_date_time_t msec: %d \n",msec);
    
    axutil_date_time_free(date_time,env);
    axutil_date_time_free(ref, env);
    axutil_date_time_free(date_time_offset, env);
    return AXIS2_SUCCESS;
}

int main()
{
    axutil_env_t *env = NULL;
    int status = AXIS2_SUCCESS;
    env = create_environment();
    status = test_date_time(env);
    if(status == AXIS2_FAILURE)
    {
        printf(" test  failed");
    }
    axutil_env_free(env);
    return 0;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to