LTP GCOV extension - code coverage report
Current view: directory - src/services/scripter_module - min_lego_interface.tests
Test: min.info
Date: 2009-06-18 Instrumented lines: 544
Code covered: 100.0 % Executed lines: 544

       1                 : /*
       2                 :  * This file is part of MIN Test Framework. Copyright © 2008 Nokia Corporation
       3                 :  * and/or its subsidiary(-ies).
       4                 :  * Contact: Konrad Marek Zapalowicz
       5                 :  * Contact e-mail: DG.MIN-Support@nokia.com
       6                 :  * 
       7                 :  * This program is free software: you can redistribute it and/or modify it 
       8                 :  * under the terms of the GNU General Public License as published by the Free 
       9                 :  * Software Foundation, version 2 of the License. 
      10                 :  * 
      11                 :  * This program is distributed in the hope that it will be useful, but WITHOUT 
      12                 :  * ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or 
      13                 :  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General  Public License for
      14                 :  * more details. You should have received a copy of the GNU General Public 
      15                 :  * License along with this program. If not,  see 
      16                 :  * <http://www.gnu.org/licenses/>.
      17                 :  */
      18                 : 
      19                 : 
      20                 : /**
      21                 :  *  @file       min_lego_interface.test
      22                 :  *  @version    0.1
      23                 :  *  @brief      This file contains test for MIN Lego Interface.
      24                 :  */
      25                 : 
      26                 : /* ------------------------------------------------------------------------- */
      27                 : /* INCLUDES */
      28                 : #include <check.h>
      29                 : 
      30                 : /* ------------------------------------------------------------------------- */
      31                 : /* CONSTANTS */
      32                 : /* None */
      33                 : 
      34                 : /* ------------------------------------------------------------------------- */
      35                 : /* MACROS */
      36                 : /* None */
      37                 : 
      38                 : /* ------------------------------------------------------------------------- */
      39                 : /* DATA TYPES */
      40                 : /* None */
      41                 : 
      42                 : /* ------------------------------------------------------------------------- */
      43                 : /* LOCAL FUNCTION PROTOTYPES */
      44                 : /* None */
      45                 : 
      46                 : /* ------------------------------------------------------------------------- */
      47                 : /* FORWARD DECLARATIONS */
      48                 : /* None */
      49                 : 
      50                 : /* ------------------------------------------------------------------------- */
      51                 : /* STRUCTURES */
      52                 : /* None */
      53                 : 
      54                 : /* ------------------------------------------------------------------------- */
      55                 : /* ==================== LOCAL FUNCTIONS ==================================== */
      56                 : /* None */
      57                 : 
      58                 : /* ------------------------------------------------------------------------- */
      59                 : /* ============================= TESTS ===================================== */
      60                 : /* ------------------------------------------------------------------------- */
      61               1 : START_TEST(test_mli_create_start)
      62                 : {
      63               1 :         LegoStartType* lst = INITPTR;
      64               1 :         lst = mli_create_start();
      65               1 :         fail_unless( lst != INITPTR, "Start Piece not created!" );
      66               1 :         DELETE(lst);
      67                 : }
      68               1 : END_TEST
      69                 : /* ------------------------------------------------------------------------- */
      70               1 : START_TEST(test_mli_create_start_2)
      71                 : {
      72               1 :         LegoStartType* lst = INITPTR;
      73               1 :         lst = mli_create_start();
      74               1 :         fail_unless( lst->type_ == ELegoStart
      75                 :                    , "Type of Start Piece differs from expected [%d]"
      76                 :                    , lst->type_ );
      77               1 :         DELETE(lst);
      78                 : }
      79               1 : END_TEST
      80                 : /* ------------------------------------------------------------------------- */
      81               1 : START_TEST(test_mli_create_start_3)
      82                 : {
      83               1 :         LegoStartType* lst = INITPTR;
      84               1 :         lst = mli_create_start();
      85               1 :         fail_unless( lst->next_ == INITPTR
      86                 :                    , "Next element of Start Piece != INITPTR" );
      87               1 :         DELETE(lst);
      88                 : }
      89               1 : END_TEST
      90                 : /* ------------------------------------------------------------------------- */
      91               1 : START_TEST(test_mli_create_end)
      92                 : {
      93               1 :         LegoStartType* lst = INITPTR;
      94               1 :         lst = mli_create_end();
      95               1 :         fail_unless( lst != INITPTR, "End Piece not created!" );
      96               1 :         DELETE(lst);
      97                 : }
      98               1 : END_TEST
      99                 : /* ------------------------------------------------------------------------- */
     100               1 : START_TEST(test_mli_create_end_2)
     101                 : {
     102               1 :         LegoStartType* lst = INITPTR;
     103               1 :         lst = mli_create_end();
     104               1 :         fail_unless( lst->type_ == ELegoEnd
     105                 :                    , "Type of End Piece differs from expected [%d]"
     106                 :                    , lst->type_ );
     107               1 :         DELETE(lst);
     108                 : }
     109               1 : END_TEST
     110                 : /* ------------------------------------------------------------------------- */
     111               1 : START_TEST(test_mli_create_end_3)
     112                 : {
     113               1 :         LegoStartType* lst = INITPTR;
     114               1 :         lst = mli_create_start();
     115               1 :         fail_unless( lst->next_ == INITPTR
     116                 :                    , "Next element of End Piece != INITPTR" );
     117               1 :         DELETE(lst);
     118                 : }
     119               1 : END_TEST
     120                 : /* ------------------------------------------------------------------------- */
     121               1 : START_TEST(test_mli_create_passive)
     122                 : {
     123               1 :         LegoPassiveType* lpt = INITPTR;
     124               1 :         TScripterKeyword key = EKeywordTitle;
     125                 : 
     126                 :         MinItemParser   mip;
     127               1 :         mip.item_line_section_         = NEW2(char,strlen("ExampleTest")+1);
     128               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     129               1 :         mip.get_methods_indicator_     = ESTrue;
     130               1 :         mip.parsing_type_              = ENormalParsing;
     131                 : 
     132               1 :         lpt = mli_create_passive( key, &mip );
     133               1 :         fail_unless( lpt != INITPTR, "Passive Piece not created" );
     134               1 :         DELETE(lpt);
     135                 : }
     136               1 : END_TEST
     137                 : /* ------------------------------------------------------------------------- */
     138               1 : START_TEST(test_mli_create_passive_2)
     139                 : {
     140               1 :         LegoPassiveType* lpt = INITPTR;
     141               1 :         TScripterKeyword key = EKeywordTitle;
     142                 : 
     143                 :         MinItemParser   mip;
     144               1 :         mip.item_line_section_         = NEW2(char,strlen("ExampleTest")+1);
     145               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     146               1 :         mip.get_methods_indicator_     = ESTrue;
     147               1 :         mip.parsing_type_              = ENormalParsing;
     148                 : 
     149               1 :         lpt = mli_create_passive( key, &mip );
     150               1 :         fail_unless( lpt->type_ == ELegoPassive
     151                 :                    , "Type of Passive Piece differs from expected [%d]"
     152                 :                    , lpt->type_ );
     153               1 :         DELETE(lpt);
     154                 : }
     155               1 : END_TEST
     156                 : /* ------------------------------------------------------------------------- */
     157               1 : START_TEST(test_mli_create_passive_3)
     158                 : {
     159               1 :         LegoPassiveType* lpt = INITPTR;
     160               1 :         TScripterKeyword key = EKeywordTitle;
     161                 : 
     162                 :         MinItemParser   mip;
     163               1 :         mip.item_line_section_         = NEW2(char,strlen("ExampleTest")+1);
     164               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     165               1 :         mip.get_methods_indicator_     = ESTrue;
     166               1 :         mip.parsing_type_              = ENormalParsing;
     167                 : 
     168               1 :         lpt = mli_create_passive( key, &mip );
     169               1 :         fail_unless( lpt->keyword_ == key
     170                 :                    , "Keyword of Passive Piece differs from expected [%d]"
     171                 :                    , lpt->keyword_ );
     172               1 :         DELETE(lpt);
     173                 : }
     174               1 : END_TEST
     175                 : /* ------------------------------------------------------------------------- */
     176               1 : START_TEST(test_mli_create_passive_4)
     177                 : {
     178               1 :         LegoPassiveType* lpt = INITPTR;
     179               1 :         TScripterKeyword key = EKeywordTitle;
     180                 : 
     181                 :         MinItemParser   mip;
     182               1 :         mip.item_line_section_         = NEW2(char,strlen("ExampleTest")+1);
     183               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     184               1 :         mip.get_methods_indicator_     = ESTrue;
     185               1 :         mip.parsing_type_              = ENormalParsing;
     186                 : 
     187               1 :         lpt = mli_create_passive( key, &mip );
     188               1 :         fail_unless( lpt->line_ == &mip
     189                 :                    , "MinItemParer of Passive Piece differs from expected [%p]"
     190                 :                    , lpt->line_ );
     191               1 :         DELETE(lpt);
     192                 : }
     193               1 : END_TEST
     194                 : /* ------------------------------------------------------------------------- */
     195               1 : START_TEST(test_mli_create_active)
     196                 : {
     197               1 :         LegoPassiveType* lpt = INITPTR;
     198               1 :         TScripterKeyword key = EKeywordCreate;
     199                 : 
     200                 :         MinItemParser   mip;
     201               1 :         mip.item_line_section_ = NEW2(char,strlen("TestModule.so foobar")+1);
     202               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     203               1 :         mip.get_methods_indicator_     = ESTrue;
     204               1 :         mip.parsing_type_              = ENormalParsing;
     205                 : 
     206               1 :         lpt = mli_create_active( key, (MinItemParser*) &mip );
     207               1 :         fail_unless( lpt != INITPTR, "Active Piece not created" );
     208               1 :         DELETE(lpt);
     209                 : }
     210               1 : END_TEST
     211                 : /* ------------------------------------------------------------------------- */
     212               1 : START_TEST(test_mli_create_active_2)
     213                 : {
     214               1 :         LegoPassiveType* lpt = INITPTR;
     215               1 :         TScripterKeyword key = EKeywordCreate;
     216                 : 
     217                 :         MinItemParser   mip;
     218               1 :         mip.item_line_section_ = NEW2(char,strlen("TestModule.so foobar")+1);
     219               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     220               1 :         mip.get_methods_indicator_     = ESTrue;
     221               1 :         mip.parsing_type_              = ENormalParsing;
     222                 : 
     223               1 :         lpt = mli_create_active( key, (MinItemParser*) &mip );
     224               1 :         fail_unless( lpt->type_ == ELegoActive
     225                 :                    , "Type of Active Piece differs from expected [%d]"
     226                 :                    , lpt->type_ );
     227               1 :         DELETE(lpt);
     228                 : }
     229               1 : END_TEST
     230                 : /* ------------------------------------------------------------------------- */
     231               1 : START_TEST(test_mli_create_active_3)
     232                 : {
     233               1 :         LegoPassiveType* lpt = INITPTR;
     234               1 :         TScripterKeyword key = EKeywordCreate;
     235                 : 
     236                 :         MinItemParser   mip;
     237               1 :         mip.item_line_section_ = NEW2(char,strlen("TestModule.so foobar")+1);
     238               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     239               1 :         mip.get_methods_indicator_     = ESTrue;
     240               1 :         mip.parsing_type_              = ENormalParsing;
     241                 : 
     242               1 :         lpt = mli_create_active( key, (MinItemParser*) &mip );
     243               1 :         fail_unless( lpt->keyword_ == key
     244                 :                    , "Keyword of Active Piece differs from expected [%d]"
     245                 :                    , lpt->keyword_ );
     246               1 :         DELETE(lpt);
     247                 : }
     248               1 : END_TEST
     249                 : /* ------------------------------------------------------------------------- */
     250               1 : START_TEST(test_mli_create_active_4)
     251                 : {
     252               1 :         LegoPassiveType* lpt = INITPTR;
     253               1 :         TScripterKeyword key = EKeywordCreate;
     254                 : 
     255                 :         MinItemParser   mip;
     256               1 :         mip.item_line_section_ = NEW2(char,strlen("TestModule.so foobar")+1);
     257               1 :         mip.item_skip_and_mark_pos_    = &mip.item_line_section_[0];
     258               1 :         mip.get_methods_indicator_     = ESTrue;
     259               1 :         mip.parsing_type_              = ENormalParsing;
     260                 : 
     261               1 :         lpt = mli_create_active( key, (MinItemParser*) &mip );
     262               1 :         fail_unless( lpt->line_ == &mip
     263                 :                    , "MinItemParer of Active Piece differs from expected [%p]"
     264                 :                    , lpt->line_ );
     265               1 :         DELETE(lpt);
     266                 : }
     267               1 : END_TEST
     268                 : /* ------------------------------------------------------------------------- */
     269               1 : START_TEST(test_mli_create_loop)
     270                 : {
     271               1 :         LegoLoopType*    llt    = INITPTR;
     272               1 :         TScripterKeyword key    = EKeywordLoop;
     273               1 :         unsigned int     iter   = 5;
     274               1 :         TSBool            tmout  = ESFalse;
     275                 : 
     276               1 :         llt = mli_create_loop(key,iter,tmout);
     277               1 :         fail_unless( llt != INITPTR, "Loop Piece not created" );
     278               1 :         DELETE(llt);
     279                 : }
     280               1 : END_TEST
     281                 : /* ------------------------------------------------------------------------- */
     282               1 : START_TEST(test_mli_create_loop_2)
     283                 : {
     284               1 :         LegoLoopType*    llt    = INITPTR;
     285               1 :         TScripterKeyword key    = EKeywordLoop;
     286               1 :         unsigned int     iter   = 5;
     287               1 :         TSBool            tmout  = ESFalse;
     288                 : 
     289               1 :         llt = mli_create_loop(key,iter,tmout);
     290               1 :         fail_unless( llt->type_ == ELegoLoop
     291                 :                    , "Type of Loop Piece differs from expected [%d]"
     292                 :                    , llt->type_ );
     293               1 :         DELETE(llt);
     294                 : }
     295               1 : END_TEST
     296                 : /* ------------------------------------------------------------------------- */
     297               1 : START_TEST(test_mli_create_loop_3)
     298                 : {
     299               1 :         LegoLoopType*    llt    = INITPTR;
     300               1 :         TScripterKeyword key    = EKeywordLoop;
     301               1 :         unsigned int     iter   = 5;
     302               1 :         TSBool            tmout  = ESFalse;
     303                 : 
     304               1 :         llt = mli_create_loop(key,iter,tmout);
     305               1 :         fail_unless( llt->next_ == INITPTR
     306                 :                    , "Next element of Loop Piece != INITPTR" );
     307               1 :         DELETE(llt);
     308                 : }
     309               1 : END_TEST
     310                 : /* ------------------------------------------------------------------------- */
     311               1 : START_TEST(test_mli_create_loop_4)
     312                 : {
     313               1 :         LegoLoopType*    llt    = INITPTR;
     314               1 :         TScripterKeyword key    = EKeywordLoop;
     315               1 :         unsigned int     iter   = 5;
     316               1 :         TSBool            tmout  = ESFalse;
     317                 : 
     318               1 :         llt = mli_create_loop(key,iter,tmout);
     319               1 :         fail_unless( llt->keyword_ == key
     320                 :                    , "Keyword of Loop Piece differs from expected [%d]"
     321                 :                    , llt->keyword_ );
     322               1 :         DELETE(llt);
     323                 : }
     324               1 : END_TEST
     325                 : /* ------------------------------------------------------------------------- */
     326               1 : START_TEST(test_mli_create_loop_5)
     327                 : {
     328               1 :         LegoLoopType*    llt    = INITPTR;
     329               1 :         TScripterKeyword key    = EKeywordLoop;
     330               1 :         unsigned int     iter   = 5;
     331               1 :         TSBool            tmout  = ESFalse;
     332                 : 
     333               1 :         llt = mli_create_loop(key,iter,tmout);
     334               1 :         fail_unless( llt->oryginal_ == iter
     335                 :                    , "No. of loops of Loop Piece differs from expected [%d]"
     336                 :                    , llt->oryginal_ );
     337               1 :         DELETE(llt);
     338                 : }
     339               1 : END_TEST
     340                 : /* ------------------------------------------------------------------------- */
     341               1 : START_TEST(test_mli_create_loop_6)
     342                 : {
     343               1 :         LegoLoopType*    llt    = INITPTR;
     344               1 :         TScripterKeyword key    = EKeywordLoop;
     345               1 :         unsigned int     iter   = 5;
     346               1 :         TSBool            tmout  = ESFalse;
     347                 : 
     348               1 :         llt = mli_create_loop(key,iter,tmout);
     349               1 :         fail_unless( llt->timeout_ == tmout
     350                 :                    , "Mode of Loop Piece differs from expected [bool(%d)]"
     351                 :                    , llt->timeout_ );
     352               1 :         DELETE(llt);
     353                 : }
     354               1 : END_TEST
     355                 : /* ------------------------------------------------------------------------- */
     356               1 : START_TEST(test_mli_create_loop_7)
     357                 : {
     358               1 :         LegoLoopType*    llt    = INITPTR;
     359               1 :         TScripterKeyword key    = EKeywordLoop;
     360               1 :         unsigned int     iter   = 5;
     361               1 :         TSBool            tmout  = ESFalse;
     362                 : 
     363               1 :         llt = mli_create_loop(key,iter,tmout);
     364               1 :         fail_unless( (LegoLoopType*)dl_list_data(dl_list_tail(loopstack))==llt
     365                 :                    , "Loop Piece not pushed to the stack" );
     366               1 :         DELETE(llt);
     367                 : }
     368               1 : END_TEST
     369                 : /* ------------------------------------------------------------------------- */
     370               1 : START_TEST(test_mli_create_endloop)
     371                 : {
     372               1 :         LegoEndloopType* let    = INITPTR;
     373               1 :         TScripterKeyword key    = EKeywordEndloop;
     374               1 :         LegoLoopType*    llt    = INITPTR;
     375               1 :         unsigned int     iter   = 5;
     376               1 :         TSBool            tmout  = ESFalse;
     377               1 :         llt = mli_create_loop(key,iter,tmout);
     378                 : 
     379               1 :         let = mli_create_endloop(key);
     380               1 :         fail_unless( let != INITPTR, "Endloop Piece not created" );
     381               1 :         DELETE(let);
     382               1 :         DELETE(llt);
     383                 : }
     384               1 : END_TEST
     385                 : /* ------------------------------------------------------------------------- */
     386               1 : START_TEST(test_mli_create_endloop_2)
     387                 : {
     388               1 :         LegoEndloopType* let    = INITPTR;
     389               1 :         TScripterKeyword key    = EKeywordEndloop;
     390               1 :         LegoLoopType*    llt    = INITPTR;
     391               1 :         unsigned int     iter   = 5;
     392               1 :         TSBool            tmout  = ESFalse;
     393               1 :         llt = mli_create_loop(key,iter,tmout);
     394                 : 
     395               1 :         let = mli_create_endloop(key);
     396               1 :         fail_unless( let->type_ == ELegoEndloop
     397                 :                    , "Type of Endloop Piece differs from expected [%d]"
     398                 :                    , let->type_ );
     399               1 :         DELETE(let);
     400               1 :         DELETE(llt);
     401                 : }
     402               1 : END_TEST
     403                 : /* ------------------------------------------------------------------------- */
     404               1 : START_TEST(test_mli_create_endloop_3)
     405                 : {
     406               1 :         LegoEndloopType* let    = INITPTR;
     407               1 :         TScripterKeyword key    = EKeywordEndloop;
     408               1 :         LegoLoopType*    llt    = INITPTR;
     409               1 :         unsigned int     iter   = 5;
     410               1 :         TSBool            tmout  = ESFalse;
     411               1 :         llt = mli_create_loop(key,iter,tmout);
     412                 : 
     413               1 :         let = mli_create_endloop(key);
     414               1 :         fail_unless( let->next_ == llt
     415                 :                    , "Next element of Endloop Piece differs from Loop Piece" );
     416               1 :         DELETE(let);
     417               1 :         DELETE(llt);
     418                 : }
     419               1 : END_TEST
     420                 : /* ------------------------------------------------------------------------- */
     421               1 : START_TEST(test_mli_create_endloop_4)
     422                 : {
     423               1 :         LegoEndloopType* let    = INITPTR;
     424               1 :         TScripterKeyword key    = EKeywordEndloop;
     425               1 :         LegoLoopType*    llt    = INITPTR;
     426               1 :         unsigned int     iter   = 5;
     427               1 :         TSBool            tmout  = ESFalse;
     428               1 :         llt = mli_create_loop(key,iter,tmout);
     429                 : 
     430               1 :         let = mli_create_endloop(key);
     431               1 :         fail_unless( let->loopback_ == llt
     432                 :                    , "Loopback of Endloop Piece differs from expected [%p]"
     433                 :                    , let->loopback_ );
     434               1 :         DELETE(let);
     435               1 :         DELETE(llt);
     436                 : 
     437                 : }
     438               1 : END_TEST
     439                 : /* ------------------------------------------------------------------------- */
     440               1 : START_TEST(test_mli_create_endloop_5)
     441                 : {
     442               1 :         LegoEndloopType* let    = INITPTR;
     443               1 :         TScripterKeyword key    = EKeywordEndloop;
     444               1 :         LegoLoopType*    llt    = INITPTR;
     445               1 :         unsigned int     iter   = 5;
     446               1 :         TSBool            tmout  = ESFalse;
     447               1 :         llt = mli_create_loop(key,iter,tmout);
     448                 : 
     449               1 :         let = mli_create_endloop(key);
     450               1 :         fail_unless( let->beyondloop_ == INITPTR
     451                 :                    , "Beyondloop of Endloop Piece differs from expected [%p]"
     452                 :                    , let->beyondloop_ );
     453               1 :         DELETE(let);
     454               1 :         DELETE(llt);
     455                 : }
     456               1 : END_TEST
     457                 : /* ------------------------------------------------------------------------- */
     458               1 : START_TEST(test_mli_create_endloop_6)
     459                 : {
     460               1 :         LegoEndloopType* let    = INITPTR;
     461               1 :         TScripterKeyword key    = EKeywordEndloop;
     462               1 :         LegoLoopType*    llt    = INITPTR;
     463               1 :         unsigned int     iter   = 5;
     464               1 :         TSBool            tmout  = ESFalse;
     465               1 :         llt = mli_create_loop(key,iter,tmout);
     466                 : 
     467               1 :         let = mli_create_endloop(key);
     468               1 :         fail_unless( let->oryginal_ == &llt->oryginal_
     469                 :                    , "No. of loops of Endloop Piece differs from expected [%d]"
     470                 :                    , *let->oryginal_ );
     471               1 :         DELETE(let);
     472               1 :         DELETE(llt);
     473                 : }
     474               1 : END_TEST
     475                 : /* ------------------------------------------------------------------------- */
     476               1 : START_TEST(test_mli_create_endloop_7)
     477                 : {
     478               1 :         LegoEndloopType* let    = INITPTR;
     479               1 :         TScripterKeyword key    = EKeywordEndloop;
     480               1 :         LegoLoopType*    llt    = INITPTR;
     481               1 :         unsigned int     iter   = 5;
     482               1 :         TSBool            tmout  = ESFalse;
     483               1 :         llt = mli_create_loop(key,iter,tmout);
     484                 : 
     485               1 :         let = mli_create_endloop(key);
     486               1 :         fail_unless( let->counter_ == 0
     487                 :                    , "Counter of Endloop Piece differs from expected [%d]"
     488                 :                    , let->counter_ );
     489               1 :         DELETE(let);
     490               1 :         DELETE(llt);
     491                 : }
     492               1 : END_TEST
     493                 : /* ------------------------------------------------------------------------- */
     494               1 : START_TEST(test_mli_create_endloop_8)
     495                 : {
     496               1 :         LegoEndloopType* let    = INITPTR;
     497               1 :         TScripterKeyword key    = EKeywordEndloop;
     498               1 :         LegoLoopType*    llt    = INITPTR;
     499               1 :         unsigned int     iter   = 5;
     500               1 :         TSBool            tmout  = ESFalse;
     501               1 :         llt = mli_create_loop(key,iter,tmout);
     502                 : 
     503               1 :         let = mli_create_endloop(key);
     504               1 :         fail_unless( let->timeout_ == llt->timeout_
     505                 :                    , "Mode of Endloop Piece differs from expected [bool(%d)]"
     506                 :                    , let->timeout_ );
     507               1 :         DELETE(let);
     508               1 :         DELETE(llt);
     509                 : }
     510               1 : END_TEST
     511                 : /* ------------------------------------------------------------------------- */
     512               1 : START_TEST(test_mli_create_endloop_9)
     513                 : {
     514               1 :         LegoEndloopType* let    = INITPTR;
     515               1 :         TScripterKeyword key    = EKeywordEndloop;
     516               1 :         LegoLoopType*    llt    = INITPTR;
     517               1 :         unsigned int     iter   = 5;
     518               1 :         TSBool            tmout  = ESFalse;
     519               1 :         llt = mli_create_loop(key,iter,tmout);
     520                 : 
     521               1 :         let = mli_create_endloop(key);
     522               1 :         fail_unless( dl_list_tail(loopstack) == DLListNULLIterator
     523                 :                    , "Loop Piece not fetched from loopstack" );
     524               1 :         DELETE(let);
     525               1 :         DELETE(llt);
     526                 : }
     527               1 : END_TEST
     528                 : /* ------------------------------------------------------------------------- */
     529               1 : START_TEST(test_mli_loopstack)
     530                 : {
     531               1 :         fail_unless( loopstack == INITPTR, "loopstack != INITPTR by default" );
     532                 : }
     533               1 : END_TEST
     534                 : /* ------------------------------------------------------------------------- */
     535               1 : START_TEST(test_mli_loopstack_2)
     536                 : {
     537               1 :         LegoLoopType*    llt    = INITPTR;
     538               1 :         TScripterKeyword key    = EKeywordLoop;
     539               1 :         unsigned int     iter   = 5;
     540               1 :         TSBool            tmout  = ESFalse;
     541               1 :         llt = mli_create_loop(key,iter,tmout);
     542                 : 
     543               1 :         fail_unless( loopstack != INITPTR
     544                 :                    , "loopstack == INITPTR after Loop Piece creation" );
     545               1 :         DELETE(llt);
     546                 : }
     547               1 : END_TEST
     548                 : /* ------------------------------------------------------------------------- */
     549               1 : START_TEST(test_mli_loopstack_3)
     550                 : {
     551               1 :         LegoLoopType*    llt    = INITPTR;
     552               1 :         TScripterKeyword key    = EKeywordLoop;
     553               1 :         unsigned int     iter   = 5;
     554               1 :         TSBool            tmout  = ESFalse;
     555               1 :         llt = mli_create_loop(key,iter,tmout);
     556                 : 
     557               1 :         fail_unless( dl_list_size(loopstack) == 1
     558                 :                    , "loopstack size differs from expected [%d]"
     559                 :                    , dl_list_size(loopstack) );
     560               1 :         DELETE(llt);
     561                 : }
     562               1 : END_TEST
     563                 : /* ------------------------------------------------------------------------- */
     564               1 : START_TEST(test_mli_loopstack_4)
     565                 : {
     566               1 :         LegoLoopType*    llt    = INITPTR;
     567               1 :         TScripterKeyword key    = EKeywordLoop;
     568               1 :         unsigned int     iter   = 5;
     569               1 :         TSBool            tmout  = ESFalse;
     570               1 :         llt = mli_create_loop(key,iter,tmout);
     571                 : 
     572               1 :         fail_unless( (LegoLoopType*)dl_list_data(dl_list_tail(loopstack))==llt
     573                 :                    , "loopstack content differs from expected" );
     574               1 :         DELETE(llt);
     575                 : }
     576               1 : END_TEST
     577                 : /* ------------------------------------------------------------------------- */
     578               1 : START_TEST(test_mli_loopstack_5)
     579                 : {
     580               1 :         LegoLoopType*    llt    = INITPTR;
     581               1 :         LegoLoopType*    llu    = INITPTR;
     582               1 :         TScripterKeyword key    = EKeywordLoop;
     583               1 :         unsigned int     iter   = 5;
     584               1 :         TSBool            tmout  = ESFalse;
     585               1 :         llt = mli_create_loop(key,iter,tmout);
     586               1 :         llu = mli_create_loop(key,iter,tmout);
     587                 : 
     588               1 :         fail_unless( dl_list_size(loopstack) == 2
     589                 :                    , "loopstack size differs from expected [%d]"
     590                 :                    , dl_list_size(loopstack) );
     591               1 :         DELETE(llt);
     592               1 :         DELETE(llu);
     593                 : }
     594               1 : END_TEST
     595                 : /* ------------------------------------------------------------------------- */
     596               1 : START_TEST(test_mli_loopstack_6)
     597                 : {
     598               1 :         LegoLoopType*    llt    = INITPTR;
     599               1 :         LegoLoopType*    llu    = INITPTR;
     600               1 :         TScripterKeyword key    = EKeywordLoop;
     601               1 :         unsigned int     iter   = 5;
     602               1 :         TSBool            tmout  = ESFalse;
     603               1 :         llt = mli_create_loop(key,iter,tmout);
     604               1 :         llu = mli_create_loop(key,iter,tmout);
     605                 : 
     606               1 :         fail_unless( (LegoLoopType*)dl_list_data(dl_list_tail(loopstack))==llu
     607                 :                    , "loopstack content differs from expected" );
     608               1 :         DELETE(llt);
     609               1 :         DELETE(llu);
     610                 : }
     611               1 : END_TEST
     612                 : /* ------------------------------------------------------------------------- */
     613               1 : START_TEST(test_mli_loopstack_7)
     614                 : {
     615               1 :         LegoLoopType*    llt    = INITPTR;
     616               1 :         LegoLoopType*    llu    = INITPTR;
     617               1 :         TScripterKeyword key    = EKeywordLoop;
     618               1 :         unsigned int     iter   = 5;
     619               1 :         TSBool            tmout  = ESFalse;
     620               1 :         llt = mli_create_loop(key,iter,tmout);
     621               1 :         llu = mli_create_loop(key,iter,tmout);
     622                 : 
     623               1 :         fail_unless( (LegoLoopType*)dl_list_data(dl_list_head(loopstack))==llt
     624                 :                    , "loopstack content differs from expected" );
     625               1 :         DELETE(llt);
     626               1 :         DELETE(llu);
     627                 : }
     628               1 : END_TEST
     629                 : /* ------------------------------------------------------------------------- */
     630               1 : START_TEST(test_mli_loopstack_8)
     631                 : {
     632               1 :         LegoLoopType*    llt    = INITPTR;
     633               1 :         LegoLoopType*    llu    = INITPTR;
     634               1 :         LegoEndloopType* let    = INITPTR;
     635               1 :         TScripterKeyword key    = EKeywordLoop;
     636               1 :         TScripterKeyword key2   = EKeywordEndloop;
     637               1 :         unsigned int     iter   = 5;
     638               1 :         TSBool            tmout  = ESFalse;
     639               1 :         llt = mli_create_loop(key,iter,tmout);
     640               1 :         llu = mli_create_loop(key,iter,tmout);
     641               1 :         let = mli_create_endloop(key2);
     642                 : 
     643               1 :         fail_unless( dl_list_size(loopstack) == 1
     644                 :                    , "loopstack size differs from expected [%d]"
     645                 :                    , dl_list_size(loopstack) );
     646                 : 
     647               1 :         DELETE(llt);
     648               1 :         DELETE(llu);
     649               1 :         DELETE(let);
     650                 : }
     651               1 : END_TEST
     652                 : /* ------------------------------------------------------------------------- */
     653               1 : START_TEST(test_mli_loopstack_9)
     654                 : {
     655               1 :         LegoLoopType*    llt    = INITPTR;
     656               1 :         LegoLoopType*    llu    = INITPTR;
     657               1 :         LegoEndloopType* let    = INITPTR;
     658               1 :         TScripterKeyword key    = EKeywordLoop;
     659               1 :         TScripterKeyword key2   = EKeywordEndloop;
     660               1 :         unsigned int     iter   = 5;
     661               1 :         TSBool            tmout  = ESFalse;
     662               1 :         llt = mli_create_loop(key,iter,tmout);
     663               1 :         llu = mli_create_loop(key,iter,tmout);
     664               1 :         let = mli_create_endloop(key2);
     665                 : 
     666               1 :         fail_unless( (LegoLoopType*)dl_list_data(dl_list_tail(loopstack))==llt
     667                 :                    , "loopstack content differs from expected" );
     668                 : 
     669               1 :         DELETE(llt);
     670               1 :         DELETE(llu);
     671               1 :         DELETE(let);
     672                 : }
     673               1 : END_TEST
     674                 : /* ------------------------------------------------------------------------- */
     675               1 : START_TEST(test_mli_loopstack_10)
     676                 : {
     677               1 :         LegoLoopType*    llt    = INITPTR;
     678               1 :         LegoLoopType*    llu    = INITPTR;
     679               1 :         LegoEndloopType* let    = INITPTR;
     680               1 :         TScripterKeyword key    = EKeywordLoop;
     681               1 :         TScripterKeyword key2   = EKeywordEndloop;
     682               1 :         unsigned int     iter   = 5;
     683               1 :         TSBool            tmout  = ESFalse;
     684               1 :         llt = mli_create_loop(key,iter,tmout);
     685               1 :         llu = mli_create_loop(key,iter,tmout);
     686               1 :         let = mli_create_endloop(key2);
     687                 : 
     688               1 :         fail_unless( dl_list_size(loopstack) == 1
     689                 :                    , "loopstack size differs from expected [%d]"
     690                 :                    , dl_list_size(loopstack) );
     691                 : 
     692               1 :         DELETE(llt);
     693               1 :         DELETE(llu);
     694               1 :         DELETE(let);
     695                 : }
     696               1 : END_TEST
     697                 : /* ------------------------------------------------------------------------- */
     698               1 : START_TEST(test_mli_loopstack_11)
     699                 : {
     700               1 :         LegoLoopType*    llt    = INITPTR;
     701               1 :         LegoLoopType*    llu    = INITPTR;
     702               1 :         LegoEndloopType* let    = INITPTR;
     703               1 :         LegoEndloopType* leu    = INITPTR;
     704               1 :         TScripterKeyword key    = EKeywordLoop;
     705               1 :         TScripterKeyword key2   = EKeywordEndloop;
     706               1 :         unsigned int     iter   = 5;
     707               1 :         TSBool            tmout  = ESFalse;
     708               1 :         llt = mli_create_loop(key,iter,tmout);
     709               1 :         llu = mli_create_loop(key,iter,tmout);
     710               1 :         let = mli_create_endloop(key2);
     711               1 :         leu = mli_create_endloop(key2);
     712                 : 
     713               1 :         fail_unless( loopstack == INITPTR
     714                 :                    , "loopstack not destroyed when empty" );
     715                 : 
     716               1 :         DELETE(llt);
     717               1 :         DELETE(llu);
     718               1 :         DELETE(let);
     719               1 :         DELETE(leu);
     720                 : }
     721               1 : END_TEST
     722                 : /* ------------------------------------------------------------------------- */
     723               1 : START_TEST(test_mli_create)
     724                 : {
     725               1 :         MinSectionParser*      msp     = INITPTR;
     726               1 :         mli_create(msp);
     727               1 :         fail_unless( legosnake == INITPTR, "Lego Snake != INITPTR" );
     728                 : }
     729               1 : END_TEST
     730                 : /* ------------------------------------------------------------------------- */
     731               1 : START_TEST(test_mli_create_2)
     732                 : {
     733               1 :         char*                   buff    = "[Test]\ntitle foo\n[Endtest]\n";
     734               1 :         MinParser*             sp      = mp_create_mem(buff,ENoComments);
     735                 :         MinSectionParser*      msp     = mp_section( sp
     736                 :                                                     , "[Test]"
     737                 :                                                     , "[Endtest]"
     738               1 :                                                     , 1 );
     739               1 :         mli_create(msp);
     740               1 :         fail_unless( legosnake != INITPTR, "Lego Snake not created" );
     741               1 :         mmp_destroy(&msp);
     742               1 :         mp_destroy(&sp);
     743                 : }
     744               1 : END_TEST
     745                 : /* ------------------------------------------------------------------------- */
     746               1 : START_TEST(test_mli_create_3)
     747                 : {
     748               1 :         char*                   buff    = "[Test]\ntitle foo\n[Endtest]\n";
     749               1 :         MinParser*             sp      = mp_create_mem(buff,ENoComments);
     750                 :         MinSectionParser*      msp     = mp_section( sp
     751                 :                                                     , "[Test]"
     752                 :                                                     , "[Endtest]"
     753               1 :                                                     , 1 );
     754               1 :         unsigned int            size    = 0;
     755               1 :         LegoBasicType*          tmp     = INITPTR;
     756                 : 
     757               1 :         mli_create(msp);
     758                 :                 
     759                 :         /* Counting number of elements on Lego Snake */
     760               1 :         tmp = legosnake;
     761               5 :         while( tmp != INITPTR ) {
     762               3 :                 size++;
     763               3 :                 tmp = tmp->next_;
     764                 :         }
     765                 : 
     766                 : 
     767               1 :         fail_unless( size == 3
     768                 :                    , "Lego Snake size differs from expected [%d]"
     769                 :                    , size );
     770               1 :         mmp_destroy(&msp);
     771               1 :         mp_destroy(&sp);
     772                 : }
     773               1 : END_TEST
     774                 : /* ------------------------------------------------------------------------- */
     775               1 : START_TEST(test_mli_create_4)
     776                 : {
     777               1 :         char*                   buff    = "[Test]\ntitle foo\n[Endtest]\n";
     778               1 :         MinParser*             sp      = mp_create_mem(buff,ENoComments);
     779                 :         MinSectionParser*      msp     = mp_section( sp
     780                 :                                                     , "[Test]"
     781                 :                                                     , "[Endtest]"
     782               1 :                                                     , 1 );
     783               1 :         mli_create(msp);
     784               1 :         fail_unless( legosnake->type_ == ELegoStart
     785                 :                    , "First Lego Piece type differs from expected [%d]"
     786                 :                    , legosnake->type_ );
     787               1 :         mmp_destroy(&msp);
     788               1 :         mp_destroy(&sp);
     789                 : }
     790               1 : END_TEST
     791                 : /* ------------------------------------------------------------------------- */
     792               1 : START_TEST(test_mli_create_5)
     793                 : {
     794               1 :         char*                   buff    = "[Test]\ntitle foo\n[Endtest]\n";
     795               1 :         MinParser*             sp      = mp_create_mem(buff,ENoComments);
     796                 :         MinSectionParser*      msp     = mp_section( sp
     797                 :                                                     , "[Test]"
     798                 :                                                     , "[Endtest]"
     799               1 :                                                     , 1 );
     800               1 :         mli_create(msp);
     801               1 :         fail_unless( legosnake->next_->type_ == ELegoPassive
     802                 :                    , "Second Lego Piece type differs from expected [%d]"
     803                 :                    , legosnake->next_->type_ );
     804               1 :         mmp_destroy(&msp);
     805               1 :         mp_destroy(&sp);
     806                 : }
     807               1 : END_TEST
     808                 : /* ------------------------------------------------------------------------- */
     809               1 : START_TEST(test_mli_create_6)
     810                 : {
     811               1 :         char*                   buff    = "[Test]\ntitle foo\n[Endtest]\n";
     812               1 :         MinParser*             sp      = mp_create_mem(buff,ENoComments);
     813                 :         MinSectionParser*      msp     = mp_section( sp
     814                 :                                                     , "[Test]"
     815                 :                                                     , "[Endtest]"
     816               1 :                                                     , 1 );
     817               1 :         mli_create(msp);
     818               1 :         fail_unless( legosnake->next_->next_->type_ == ELegoEnd
     819                 :                    , "Last Lego Piece type differs from expected [%d]"
     820                 :                    , legosnake->next_->next_->type_ );
     821               1 :         mmp_destroy(&msp);
     822               1 :         mp_destroy(&sp);
     823                 : }
     824               1 : END_TEST
     825                 : /* ------------------------------------------------------------------------- */
     826                 : /* ------------------------------------------------------------------------- */
     827                 : /* ------------------------------------------------------------------------- */
     828                 : /* ------------------------------------------------------------------------- */
     829                 : /* ------------------------------------------------------------------------- */
     830                 : /* ------------------------------------------------------------------------- */
     831                 : /* ========================== FUNCTIONS ==================================== */
     832                 : /* ------------------------------------------------------------------------- */
     833                 : Suite* min_lego_interface_suite()
     834              48 : {
     835              48 :         Suite * s = suite_create ("min lego interface");
     836                 :         /* Core test case */
     837              48 :         TCase *tc_core = tcase_create ("Core");
     838                 : 
     839                 :         /* mli_create_start */
     840              48 :         tcase_add_test (tc_core, test_mli_create_start);
     841              48 :         tcase_add_test (tc_core, test_mli_create_start_2);
     842              48 :         tcase_add_test (tc_core, test_mli_create_start_3);
     843                 : 
     844                 :         /* mli_create_end */
     845              48 :         tcase_add_test (tc_core, test_mli_create_end);
     846              48 :         tcase_add_test (tc_core, test_mli_create_end_2);
     847              48 :         tcase_add_test (tc_core, test_mli_create_end_3);
     848                 : 
     849                 :         /* mli_create_passive */
     850              48 :         tcase_add_test (tc_core, test_mli_create_passive);
     851              48 :         tcase_add_test (tc_core, test_mli_create_passive_2);
     852              48 :         tcase_add_test (tc_core, test_mli_create_passive_3);
     853              48 :         tcase_add_test (tc_core, test_mli_create_passive_4);
     854                 : 
     855                 :         /* mli_create_active */
     856              48 :         tcase_add_test (tc_core, test_mli_create_active);
     857              48 :         tcase_add_test (tc_core, test_mli_create_active_2);
     858              48 :         tcase_add_test (tc_core, test_mli_create_active_3);
     859              48 :         tcase_add_test (tc_core, test_mli_create_active_4);
     860                 : 
     861                 :         /* mli_create_loop */
     862              48 :         tcase_add_test (tc_core, test_mli_create_loop);
     863              48 :         tcase_add_test (tc_core, test_mli_create_loop_2);
     864              48 :         tcase_add_test (tc_core, test_mli_create_loop_3);
     865              48 :         tcase_add_test (tc_core, test_mli_create_loop_4);
     866              48 :         tcase_add_test (tc_core, test_mli_create_loop_5);
     867              48 :         tcase_add_test (tc_core, test_mli_create_loop_6);
     868              48 :         tcase_add_test (tc_core, test_mli_create_loop_7);
     869                 : 
     870                 :         /* mli_create_endloop */
     871              48 :         tcase_add_test (tc_core, test_mli_create_endloop);
     872              48 :         tcase_add_test (tc_core, test_mli_create_endloop_2);
     873              48 :         tcase_add_test (tc_core, test_mli_create_endloop_3);
     874              48 :         tcase_add_test (tc_core, test_mli_create_endloop_4);
     875              48 :         tcase_add_test (tc_core, test_mli_create_endloop_5);
     876              48 :         tcase_add_test (tc_core, test_mli_create_endloop_6);
     877              48 :         tcase_add_test (tc_core, test_mli_create_endloop_7);
     878              48 :         tcase_add_test (tc_core, test_mli_create_endloop_8);
     879              48 :         tcase_add_test (tc_core, test_mli_create_endloop_9);
     880                 : 
     881                 :         /* mli_mli_loopstack */
     882              48 :         tcase_add_test (tc_core, test_mli_loopstack);
     883              48 :         tcase_add_test (tc_core, test_mli_loopstack_2);
     884              48 :         tcase_add_test (tc_core, test_mli_loopstack_3);
     885              48 :         tcase_add_test (tc_core, test_mli_loopstack_4);
     886              48 :         tcase_add_test (tc_core, test_mli_loopstack_5);
     887              48 :         tcase_add_test (tc_core, test_mli_loopstack_6);
     888              48 :         tcase_add_test (tc_core, test_mli_loopstack_7);
     889              48 :         tcase_add_test (tc_core, test_mli_loopstack_8);
     890              48 :         tcase_add_test (tc_core, test_mli_loopstack_9);
     891              48 :         tcase_add_test (tc_core, test_mli_loopstack_10);
     892              48 :         tcase_add_test (tc_core, test_mli_loopstack_11);
     893                 : 
     894                 :         /* mli_create */
     895              48 :         tcase_add_test (tc_core, test_mli_create);
     896              48 :         tcase_add_test (tc_core, test_mli_create_2);
     897              48 :         tcase_add_test (tc_core, test_mli_create_3);
     898              48 :         tcase_add_test (tc_core, test_mli_create_4);
     899              48 :         tcase_add_test (tc_core, test_mli_create_5);
     900              48 :         tcase_add_test (tc_core, test_mli_create_6);
     901                 : 
     902                 :         /* mli_destroy */
     903                 : 
     904                 : 
     905              48 :         suite_add_tcase (s, tc_core);
     906              48 :         return s;
     907                 : }
     908                 : /* ------------------------------------------------------------------------- */
     909                 : int min_lego_interface_tests()
     910              48 : {
     911              48 :         int number_failed = 0;
     912              48 :         Suite   * s  = min_lego_interface_suite ();
     913              48 :         SRunner * sr = srunner_create (s);
     914              48 :         srunner_run_all(sr, CK_NORMAL);
     915               1 :         number_failed = srunner_ntests_failed(sr);
     916               1 :         srunner_free(sr);
     917               1 :         return number_failed;
     918                 : }
     919                 : /* ------------------------------------------------------------------------- */
     920                 : /* End of file */

Generated by: LTP GCOV extension version 1.6