Ticket #1422: 0001-sptest-sp2038-Add-a-test-for-leap-year.patch

File 0001-sptest-sp2038-Add-a-test-for-leap-year.patch, 1.7 KB (added by Chirayu Desai, on Dec 5, 2013 at 3:52:56 PM)

Testcase

  • testsuites/sptests/sp2038/init.c

    From 0fde7f80af44e7346879e027b5245915d3b418f5 Mon Sep 17 00:00:00 2001
    From: Chirayu Desai <cdesai@cyanogenmod.org>
    Date: Thu, 5 Dec 2013 21:57:14 +0530
    Subject: [PATCH] sptest: sp2038: Add a test for leap year
    
    Bug test case for PR 1422
    ---
     testsuites/sptests/sp2038/init.c | 32 ++++++++++++++++++++++++++++++++
     1 file changed, 32 insertions(+)
    
    diff --git a/testsuites/sptests/sp2038/init.c b/testsuites/sptests/sp2038/init.c
    index e0179e9..08a181c 100644
    a b static const rtems_time_of_day problem_2106 = { 
    189189  .second = 16
    190190};
    191191
     192static const rtems_time_of_day problem_2100 = {
     193  .year = 2100,
     194  .month = 2,
     195  .day = 28,
     196  .hour = 0,
     197  .minute = 0,
     198  .second = 0
     199};
     200
     201static const rtems_time_of_day problem_2100_2 = {
     202  .year = 2100,
     203  .month = 2,
     204  .day = 29,
     205  .hour = 0,
     206  .minute = 0,
     207  .second = 0
     208};
     209
    192210static void test_tod_to_seconds(void)
    193211{
    194212  rtems_status_code sc = RTEMS_SUCCESSFUL;
    static void test_problem_year(void) 
    251269#endif /* TEST_APPLICABLE */
    252270}
    253271
     272static void test_leap_year(void)
     273{
     274    bool test_status;
     275    const rtems_time_of_day *problem = &problem_2100;
     276    const rtems_time_of_day *problem2 = &problem_2100_2;
     277    // 2100 is not a leap year, so it should have 28 days
     278    test_status = _TOD_Validate(problem);
     279    rtems_test_assert(test_status == true);
     280    test_status = _TOD_Validate(problem2);
     281    rtems_test_assert(test_status == false);
     282}
     283
     284
    254285rtems_task Init(rtems_task_argument argument)
    255286{
    256287  puts("\n\n*** TEST 2038 ***");
    257288
    258289  test_tod_to_seconds();
    259290  test_problem_year();
     291  test_leap_year();
    260292
    261293  puts("*** END OF TEST 2038 ***");
    262294