LTP GCOV extension - code coverage report
Current view: directory - src/utils/parser - min_file_parser.tests
Test: min.info
Date: 2009-06-18 Instrumented lines: 608
Code covered: 100.0 % Executed lines: 608

       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_file_parser.test
      22                 :  *  @version    0.1
      23                 :  *  @brief      This file contains test for MIN File Parser
      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_mfp_create)
      62                 : {
      63               1 :         FILE           * fp  = INITPTR;
      64               1 :         MinFileParser * sfp = INITPTR;
      65                 : 
      66               1 :         sfp = mfp_create( fp
      67                 :                         , EFileNotUnicode
      68                 :                         , ENoComments );
      69                 : 
      70               1 :         fail_unless( sfp == INITPTR
      71                 :                    , "sfp != INITPTR" );
      72                 : }
      73               1 : END_TEST
      74                 : /* ------------------------------------------------------------------------- */
      75               1 : START_TEST(test_mfp_create2)
      76                 : {
      77               1 :         FILE           * fp  = INITPTR;
      78               1 :         MinFileParser * sfp = INITPTR;
      79                 : 
      80               1 :         fp  = fopen("min.cfg","rb");
      81               1 :         sfp = mfp_create( fp
      82                 :                         , EFileNotUnicode
      83                 :                         , ENoComments );
      84                 : 
      85               1 :         fail_unless( sfp != INITPTR
      86                 :                    , "sfp == INITPTR" );
      87                 : 
      88               1 :         mfp_destroy(&sfp);
      89                 : }
      90               1 : END_TEST
      91                 : /* ------------------------------------------------------------------------- */
      92               1 : START_TEST(test_mfp_create3)
      93                 : {
      94               1 :         FILE           * fp  = INITPTR;
      95               1 :         MinFileParser * sfp = INITPTR;
      96                 : 
      97               1 :         fp  = fopen("min.cfg","rb");
      98               1 :         sfp = mfp_create( fp
      99                 :                         , EFileNotUnicode
     100                 :                         , ENoComments );
     101                 : 
     102               1 :         fail_unless( sfp->base_file_ == fp
     103                 :                    , "sfp->base_file_ != fp" );
     104                 : 
     105               1 :         mfp_destroy(&sfp);
     106                 : }
     107               1 : END_TEST
     108                 : /* ------------------------------------------------------------------------- */
     109               1 : START_TEST(test_mfp_create4)
     110                 : {
     111               1 :         FILE           * fp  = INITPTR;
     112               1 :         MinFileParser * sfp = INITPTR;
     113                 : 
     114               1 :         fp  = fopen("min.cfg","rb");
     115               1 :         sfp = mfp_create( fp
     116                 :                         , EFileNotUnicode
     117                 :                         , ENoComments );
     118                 : 
     119               1 :         fail_unless( sfp->comment_type_ == ENoComments
     120                 :                    , "Comment type differs from expected" );
     121                 : 
     122               1 :         mfp_destroy(&sfp);
     123                 : }
     124               1 : END_TEST
     125                 : /* ------------------------------------------------------------------------- */
     126               1 : START_TEST(test_mfp_create5)
     127                 : {
     128               1 :         FILE           * fp  = INITPTR;
     129               1 :         MinFileParser * sfp = INITPTR;
     130                 : 
     131               1 :         fp  = fopen("min.cfg","rb");
     132               1 :         sfp = mfp_create( fp
     133                 :                         , EFileNotUnicode
     134                 :                         , ENoComments );
     135                 : 
     136               1 :         fail_unless( sfp->is_unicode_ == EFileNotUnicode
     137                 :                    , "sfp->is_unicode_ differs from expected [%d]"
     138                 :                    , sfp->is_unicode_ );
     139                 : 
     140               1 :         mfp_destroy(&sfp);
     141                 : }
     142               1 : END_TEST
     143                 : /* ------------------------------------------------------------------------- */
     144               1 : START_TEST(test_mfp_create6)
     145                 : {
     146               1 :         FILE           * fp  = INITPTR;
     147               1 :         MinFileParser * sfp = INITPTR;
     148                 : 
     149               1 :         fp  = fopen("min.cfg","rb");
     150               1 :         sfp = mfp_create( fp
     151                 :                         , EFileNotUnicode
     152                 :                         , ENoComments );
     153                 : 
     154               1 :         fail_unless( sfp->bytes_per_char_ == 1
     155                 :                    , "Bytes per char has inproper value" );
     156                 : 
     157               1 :         mfp_destroy(&sfp);
     158                 : }
     159               1 : END_TEST
     160                 : /* ------------------------------------------------------------------------- */
     161               1 : START_TEST(test_mfp_create7)
     162                 : {
     163               1 :         FILE           * fp  = INITPTR;
     164               1 :         MinFileParser * sfp = INITPTR;
     165                 : 
     166               1 :         fp  = fopen("min.cfg","rb");
     167               1 :         sfp = mfp_create( fp
     168                 :                         , EFileNotUnicode
     169                 :                         , ENoComments );
     170                 : 
     171               1 :         fail_unless( sfp->current_file_ == sfp->base_file_
     172                 :                    , "sfp->current_file_ differs from expected" );
     173                 : 
     174               1 :         mfp_destroy(&sfp);
     175                 : }
     176               1 : END_TEST
     177                 : /* ------------------------------------------------------------------------- */
     178               1 : START_TEST(test_mfp_create8)
     179                 : {
     180               1 :         FILE           * fp  = INITPTR;
     181               1 :         MinFileParser * sfp = INITPTR;
     182                 : 
     183               1 :         fp  = fopen("min.cfg","rb");
     184               1 :         sfp = mfp_create( fp
     185                 :                         , EFileNotUnicode
     186                 :                         , ENoComments );
     187                 : 
     188               1 :         fail_unless( sfp->file_stack_ != INITPTR
     189                 :                    , "Allocating of DLList has failed" );
     190                 : 
     191               1 :         mfp_destroy(&sfp);
     192                 : }
     193               1 : END_TEST
     194                 : /* ------------------------------------------------------------------------- */
     195               1 : START_TEST(test_mfp_create9)
     196                 : {
     197               1 :         FILE           * fp  = INITPTR;
     198               1 :         MinFileParser * sfp = INITPTR;
     199                 : 
     200               1 :         fp  = fopen("min.cfg","rb");
     201               1 :         sfp = mfp_create( fp
     202                 :                         , EFileNotUnicode
     203                 :                         , ENoComments );
     204                 : 
     205               1 :         fail_unless( sfp->file_stack_ != INITPTR
     206                 :                    , "sfp->file_stack_ == INITPTR" );
     207                 : 
     208               1 :         mfp_destroy(&sfp);
     209                 : }
     210               1 : END_TEST
     211                 : /* ------------------------------------------------------------------------- */
     212               1 : START_TEST(test_mfp_create10)
     213                 : {
     214               1 :         FILE           * fp  = INITPTR;
     215               1 :         MinFileParser * sfp = INITPTR;
     216                 : 
     217               1 :         fp  = fopen("min.cfg","rb");
     218               1 :         sfp = mfp_create( fp
     219                 :                         , EFileNotUnicode
     220                 :                         , ENoComments );
     221                 : 
     222               1 :         fail_unless( sfp->file_names_ != INITPTR
     223                 :                    , "sfp->file_names_ == INITPTR" );
     224                 : 
     225               1 :         mfp_destroy(&sfp);
     226                 : }
     227               1 : END_TEST
     228                 : /* ------------------------------------------------------------------------- */
     229               1 : START_TEST(test_mfp_create11)
     230                 : {
     231               1 :         FILE           * fp  = INITPTR;
     232               1 :         MinFileParser * sfp = INITPTR;
     233                 : 
     234               1 :         fp  = fopen("min.cfg","rb");
     235               1 :         sfp = mfp_create( fp
     236                 :                         , EFileNotUnicode
     237                 :                         , ENoComments );
     238                 : 
     239               1 :         fail_unless( dl_list_size(sfp->file_names_) == 1
     240                 :                    , "dl_list_size(sfp->file_names_) != 1 [%d]"
     241                 :                    , dl_list_size(sfp->file_names_) );
     242                 : 
     243               1 :         mfp_destroy(&sfp);
     244                 : }
     245               1 : END_TEST
     246                 : /* ------------------------------------------------------------------------- */
     247               1 : START_TEST(test_mfp_create12)
     248                 : {
     249               1 :         FILE           * fp  = INITPTR;
     250               1 :         MinFileParser * sfp = INITPTR;
     251                 : 
     252               1 :         fp  = fopen("min.cfg","rb");
     253               1 :         sfp = mfp_create( fp
     254                 :                         , EFileNotUnicode
     255                 :                         , ENoComments );
     256                 : 
     257               1 :         fail_unless( dl_list_size(sfp->file_stack_) == 0
     258                 :                    , "dl_list_size(sfp->file_stack_) != 0 [%d]"
     259                 :                    , dl_list_size(sfp->file_stack_) );
     260                 : 
     261               1 :         mfp_destroy(&sfp);
     262                 : }
     263               1 : END_TEST
     264                 : /* ------------------------------------------------------------------------- */
     265               1 : START_TEST(test_mfp_destroy)
     266                 : {
     267               1 :         MinFileParser * sfp = INITPTR;
     268               1 :         mfp_destroy(&sfp);
     269               1 :         fail_unless( sfp == INITPTR
     270                 :                    , "Pointer not nulled after deletion" );
     271                 : }
     272               1 : END_TEST
     273                 : /* ------------------------------------------------------------------------- */
     274               1 : START_TEST(test_mfp_destroy2)
     275                 : {
     276               1 :         FILE           * fp  = fopen("mfp_test.txt","rb");
     277               1 :         MinFileParser * sfp = mfp_create( fp, 1, ENoComments );
     278               1 :         mfp_destroy(&sfp);
     279               1 :         fail_unless( sfp == INITPTR, "Pointer not nulled after deletion" );
     280                 : }
     281               1 : END_TEST
     282                 : /* ------------------------------------------------------------------------- */
     283               1 : START_TEST(test_mfp_read_line)
     284                 : {
     285               1 :         MinFileParser * sfp    = INITPTR;
     286               1 :         char           * buffer = INITPTR;
     287               1 :         int              retval = 0;
     288                 :         char             eol[3];
     289                 : 
     290               1 :         retval = mfp_read_line( sfp
     291                 :                               , &buffer
     292                 :                               , eol );
     293                 : 
     294               1 :         fail_unless( retval == ESFalse
     295                 :                    , "Returned value differs from expected [%d]"
     296                 :                    , retval );
     297                 : }
     298               1 : END_TEST
     299                 : /* ------------------------------------------------------------------------- */
     300               1 : START_TEST(test_mfp_read_line2)
     301                 : {
     302               1 :         MinFileParser * sfp    = INITPTR;
     303               1 :         char           * buffer = INITPTR;
     304               1 :         int              retval = 0;
     305                 :         char             eol[3];
     306                 : 
     307               1 :         retval = mfp_read_line( sfp
     308                 :                               , &buffer
     309                 :                               , eol );
     310                 : 
     311               1 :         fail_unless( buffer == INITPTR
     312                 :                    , "buffer != INITPTR" );
     313                 : }
     314               1 : END_TEST
     315                 : /* ------------------------------------------------------------------------- */
     316               1 : START_TEST(test_mfp_read_line3)
     317                 : {
     318               1 :         FILE           * fp     = fopen("min.cfg","r");
     319               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     320               1 :         char           * buffer = INITPTR;
     321               1 :         int              retval = 0;
     322                 :         char             eol[3];
     323                 : 
     324               1 :         retval = mfp_read_line( sfp
     325                 :                               , &buffer
     326                 :                               , eol );
     327                 : 
     328               1 :         fail_unless( retval = ESTrue
     329                 :                    , "Returned value differs from expected [%d]"
     330                 :                    , retval );
     331                 : 
     332               1 :         free(buffer);
     333               1 :         mfp_destroy(&sfp);
     334                 : }
     335               1 : END_TEST
     336                 : /* ------------------------------------------------------------------------- */
     337               1 : START_TEST(test_mfp_read_line4)
     338                 : {
     339               1 :         FILE           * fp     = fopen("min.cfg","r");
     340               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     341               1 :         char           * buffer = INITPTR;
     342               1 :         int              retval = 0;
     343                 :         char             eol[3];
     344                 : 
     345               1 :         retval = mfp_read_line( sfp
     346                 :                               , &buffer
     347                 :                               , eol );
     348                 : 
     349               1 :         fail_unless( buffer != INITPTR
     350                 :                    , "buffer == INITPTR" );
     351                 : 
     352               1 :         free(buffer);
     353               1 :         mfp_destroy(&sfp);
     354                 : }
     355               1 : END_TEST
     356                 : /* ------------------------------------------------------------------------- */
     357               1 : START_TEST(test_mfp_read_line5)
     358                 : {
     359               1 :         FILE           * fp     = fopen("min.cfg","r");
     360               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     361               1 :         char           * buffer = INITPTR;
     362               1 :         int              retval = 0;
     363                 :         char             eol[3];
     364                 : 
     365               1 :         retval = mfp_read_line( sfp
     366                 :                               , &buffer
     367                 :                               , eol );
     368                 : 
     369               1 :         fail_unless( strcmp(buffer,"#") == 0
     370                 :                    , "Result differs from expected [%s]"
     371                 :                    , buffer );
     372                 : 
     373               1 :         free(buffer);
     374               1 :         mfp_destroy(&sfp);
     375                 : }
     376               1 : END_TEST
     377                 : /* ------------------------------------------------------------------------- */
     378               1 : START_TEST(test_mfp_read_line6)
     379                 : {
     380               1 :         FILE           * fp     = fopen("min.cfg","r");
     381               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     382               1 :         char           * buffer = INITPTR;
     383               1 :         int              retval = 0;
     384                 :         char             eol[3];
     385                 : 
     386               1 :         retval = mfp_read_line( sfp
     387                 :                               , &buffer
     388                 :                               , eol );
     389                 : 
     390               1 :         fail_unless( eol[0] == '\n'
     391                 :                    , "EOL is wrong [%s]"
     392                 :                    , eol );
     393                 : 
     394               1 :         free(buffer);
     395               1 :         mfp_destroy(&sfp);
     396                 : }
     397               1 : END_TEST
     398                 : /* ------------------------------------------------------------------------- */
     399               1 : START_TEST(test_mfp_read_line7)
     400                 : {
     401               1 :         FILE           * fp     = fopen("min.cfg","r");
     402               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     403               1 :         char           * buffer = INITPTR;
     404               1 :         int              retval = 0;
     405                 :         char             eol[3];
     406                 : 
     407               1 :         retval = mfp_read_line( sfp
     408                 :                               , &buffer
     409                 :                               , eol );
     410               1 :         free(buffer);
     411               1 :         retval = mfp_read_line( sfp
     412                 :                               , &buffer
     413                 :                               , eol );
     414                 : 
     415               1 :         fail_unless( strcmp(buffer,"# This is MIN parser test file") == 0
     416                 :                    , "Result differs from expected [%s]"
     417                 :                    , buffer );
     418                 : 
     419               1 :         free(buffer);
     420               1 :         mfp_destroy(&sfp);
     421                 : }
     422               1 : END_TEST
     423                 : /* ------------------------------------------------------------------------- */
     424               1 : START_TEST(test_mfp_read_line8)
     425                 : {
     426               1 :         FILE           * fp     = fopen("min.cfg","r");
     427               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     428               1 :         char           * buffer = INITPTR;
     429               1 :         int              retval = 0;
     430                 :         char             eol[3];
     431                 : 
     432               1 :         retval = mfp_read_line( sfp
     433                 :                               , &buffer
     434                 :                               , eol );
     435               1 :         free(buffer);
     436               1 :         retval = mfp_read_line( sfp
     437                 :                               , &buffer
     438                 :                               , eol );
     439                 : 
     440               1 :         fail_unless( strcmp(eol,"\n") == 0
     441                 :                    , "Result differs from expected [%s]"
     442                 :                    , buffer );
     443                 : 
     444               1 :         free(buffer);
     445               1 :         mfp_destroy(&sfp);
     446                 : }
     447               1 : END_TEST
     448                 : /* ------------------------------------------------------------------------- */
     449               1 : START_TEST(test_mfp_replace_comments_line)
     450                 : {
     451               1 :         char* output = INITPTR;
     452                 : 
     453               1 :         mfp_replace_comments_line( INITPTR
     454                 :                                  , &output
     455                 :                                  , EQuota );
     456                 : 
     457               1 :         fail_unless( output == INITPTR
     458                 :                    , "output != INITPTR" );
     459                 : }
     460               1 : END_TEST
     461                 : /* ------------------------------------------------------------------------- */
     462               1 : START_TEST(test_mfp_replace_comments_line2)
     463                 : {
     464               1 :         char  text[] = "A\"la \"ma kota";
     465               1 :         char* output = INITPTR;
     466                 : 
     467               1 :         mfp_replace_comments_line( text
     468                 :                                  , &output
     469                 :                                  , EQuota );
     470                 : 
     471               1 :         fail_unless( output != INITPTR
     472                 :                    , "output == INITPTR" );
     473                 : }
     474               1 : END_TEST
     475                 : /* ------------------------------------------------------------------------- */
     476               1 : START_TEST(test_mfp_replace_comments_line3)
     477                 : {
     478               1 :         char text[] = "A\"la \"ma kota";
     479                 :         char* output;
     480               1 :         mfp_replace_comments_line( text
     481                 :                                  , &output
     482                 :                                  , EQuota );
     483               1 :         fail_unless( strcmp(output,"la") == 0
     484                 :                    , "Result differs from expected [%s]"
     485                 :                    , output );
     486               1 :         free(output);
     487                 : }
     488               1 : END_TEST
     489                 : /* ------------------------------------------------------------------------- */
     490               1 : START_TEST(test_mfp_replace_comments_line4)
     491                 : {
     492               1 :         char  text[] = "Ala ma kota kot ma ale\n";
     493                 :         char* output;
     494               1 :         mfp_replace_comments_line( text
     495                 :                                  , &output
     496                 :                                  , EQuota );
     497               1 :         fail_unless( strcmp(output,"") == 0
     498                 :                    , "Result differs from expected [%s]"
     499                 :                    , output );
     500               1 :         free(output);
     501                 : }
     502               1 : END_TEST
     503                 : /* ------------------------------------------------------------------------- */
     504               1 : START_TEST(test_mfp_replace_comments_line5)
     505                 : {
     506               1 :         char text[] = "A\"la \"ma kota/* kot */m*a // ale";
     507                 :         char* output;
     508               1 :         mfp_replace_comments_line( text
     509                 :                                  , &output
     510                 :                                  , EStart );
     511               1 :         fail_unless( strcmp(output,"A     ma kota         m*a") == 0
     512                 :                    , "Result differs from expected [%s]"
     513                 :                    , output );
     514               1 :         free(output);
     515                 : }
     516               1 : END_TEST
     517                 : /* ------------------------------------------------------------------------- */
     518               1 : START_TEST(test_mfp_replace_comments_line6)
     519                 : {
     520               1 :         char text[] = "Ala ma kota kot ma ale";
     521                 :         char* output;
     522               1 :         mfp_replace_comments_line( text
     523                 :                                  , &output
     524                 :                                  , EStart );
     525               1 :         fail_unless( strcmp(output,text) == 0
     526                 :                    , "Result differs from expected [%s]"
     527                 :                    , output );
     528               1 :         free(output);
     529                 : }
     530               1 : END_TEST
     531                 : /* ------------------------------------------------------------------------- */
     532               1 : START_TEST(test_mfp_replace_comments_line7)
     533                 : {
     534               1 :         char text[] = "A\"la \"ma kota/* kot */m*a // ale";
     535                 :         char* output;
     536               1 :         mfp_replace_comments_line( text
     537                 :                                  , &output
     538                 :                                  , EQuota );
     539               1 :         fail_unless( strcmp(output,"la") == 0
     540                 :                    , "Result differs from expected [%s]"
     541                 :                    , output );
     542               1 :         free(output);
     543                 : }
     544               1 : END_TEST
     545                 : /* ------------------------------------------------------------------------- */
     546               1 : START_TEST(test_mfp_replace_hash_comments_line)
     547                 : {
     548               1 :         char* output = INITPTR;
     549               1 :         mfp_replace_hash_comments_line( INITPTR
     550                 :                                       , &output );
     551               1 :         fail_unless( output == INITPTR
     552                 :                    , "output != INITPTR" );
     553                 : }
     554               1 : END_TEST
     555                 : /* ------------------------------------------------------------------------- */
     556               1 : START_TEST(test_mfp_replace_hash_comments_line2)
     557                 : {
     558               1 :         char  text[] = "A#ma kota";
     559               1 :         char* output = INITPTR;
     560               1 :         mfp_replace_hash_comments_line( text
     561                 :                                       , &output );
     562               1 :         fail_unless( output != INITPTR
     563                 :                    , "output == INITPTR" );
     564               1 :         free(output);
     565                 : }
     566               1 : END_TEST
     567                 : /* ------------------------------------------------------------------------- */
     568               1 : START_TEST(test_mfp_replace_hash_comments_line3)
     569                 : {
     570               1 :         char  text[] = "A#ma kota";
     571               1 :         char* output = INITPTR;
     572               1 :         mfp_replace_hash_comments_line( text
     573                 :                                       , &output );
     574               1 :         fail_unless( strcmp(output,"A") == 0
     575                 :                    , "Returned value differs from expected [%s]"
     576                 :                    , output );
     577               1 :         free(output);
     578                 : }
     579               1 : END_TEST
     580                 : /* ------------------------------------------------------------------------- */
     581               1 : START_TEST(test_mfp_replace_hash_comments_line4)
     582                 : {
     583               1 :         char  text[] = "A ma kota";
     584               1 :         char* output = INITPTR;
     585               1 :         mfp_replace_hash_comments_line( text
     586                 :                                       , &output );
     587               1 :         fail_unless( strcmp(output,text) == 0
     588                 :                    , "Returned value differs from expected [%s]"
     589                 :                    , output );
     590               1 :         free(output);
     591                 : }
     592               1 : END_TEST
     593                 : /* ------------------------------------------------------------------------- */
     594               1 : START_TEST(test_mfp_replace_hash_comments_line5)
     595                 : {
     596               1 :         char  text[] = "";
     597               1 :         char* output = INITPTR;
     598               1 :         mfp_replace_hash_comments_line( text
     599                 :                                       , &output );
     600               1 :         fail_unless( strcmp(output,text) == 0
     601                 :                    , "Returned value differs from expected [%s]"
     602                 :                    , output );
     603               1 :         free(output);
     604                 : }
     605               1 : END_TEST
     606                 : /* ------------------------------------------------------------------------- */
     607               1 : START_TEST(test_mfp_replace_hash_comments_line6)
     608                 : {
     609               1 :         char  text[] = "#";
     610               1 :         char* output = INITPTR;
     611               1 :         mfp_replace_hash_comments_line( text
     612                 :                                       , &output );
     613               1 :         fail_unless( strcmp(output,"") == 0
     614                 :                    , "Returned value differs from expected [%s]"
     615                 :                    , output );
     616               1 :         free(output);
     617                 : }
     618               1 : END_TEST
     619                 : /* ------------------------------------------------------------------------- */
     620               1 : START_TEST(test_mfp_replace_hash_comments_line7)
     621                 : {
     622               1 :         char  text[] = "Ala#ma kota#kot ma ale";
     623               1 :         char* output = INITPTR;
     624               1 :         mfp_replace_hash_comments_line( text
     625                 :                                       , &output );
     626               1 :         fail_unless( strcmp(output,"Ala") == 0
     627                 :                    , "Returned value differs from expected [%s]"
     628                 :                    , output );
     629               1 :         free(output);
     630                 : }
     631               1 : END_TEST
     632                 : /* ------------------------------------------------------------------------- */
     633               1 : START_TEST(test_mfp_clear_file_stack)
     634                 : {
     635               1 :         MinFileParser* sfp = INITPTR;
     636               1 :         mfp_clear_file_stack( sfp );
     637                 : }
     638               1 : END_TEST
     639                 : /* ------------------------------------------------------------------------- */
     640               1 : START_TEST(test_mfp_clear_file_stack2)
     641                 : {
     642               1 :         FILE           * fp     = fopen("min.cfg","r");
     643               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     644               1 :         mfp_clear_file_stack( sfp );
     645                 : 
     646               1 :         fail_unless( sfp->file_stack_ != INITPTR
     647                 :                    , "sfp->file_stack_ == INITPTR" );
     648                 : }
     649               1 : END_TEST
     650                 : /* ------------------------------------------------------------------------- */
     651               1 : START_TEST(test_mfp_clear_file_stack3)
     652                 : {
     653               1 :         FILE           * fp     = fopen("min.cfg","r");
     654               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     655               1 :         mfp_clear_file_stack( sfp );
     656                 : 
     657               1 :         fail_unless( dl_list_size(sfp->file_stack_) == 0
     658                 :                    , "sfp->file_stack_ not empty after clear operation [%d]"
     659                 :                    , dl_list_size(sfp->file_stack_) );
     660                 : }
     661               1 : END_TEST
     662                 : /* ------------------------------------------------------------------------- */
     663               1 : START_TEST(test_mfp_clear_file_stack4)
     664                 : {
     665               1 :         char             path[] = "/home/maemo/work/min/debug/tests/module.cfg";
     666               1 :         char             path2[]= "/home/maemo/work/min/debug/tests/file.cfg";
     667               1 :         FILE           * fp     = fopen("min.cfg","r");
     668               1 :         FILE           * fp2    = fopen("module.cfg","r");
     669               1 :         FILE           * fp3    = fopen("file.cfg","r");
     670               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     671               1 :         FILE*            fi     = INITPTR;
     672                 : 
     673               1 :         dl_list_add(sfp->file_names_,path);
     674               1 :         dl_list_add(sfp->file_names_,path2);
     675               1 :         dl_list_add( sfp->file_stack_, fp2 );
     676               1 :         dl_list_add( sfp->file_stack_, fp3 );
     677                 : 
     678               1 :         mfp_clear_file_stack( sfp );
     679                 : 
     680               1 :         fail_unless( dl_list_size(sfp->file_stack_) == 0
     681                 :                    , "sfp->file_stack_ not empty after clear operation [%d]"
     682                 :                    , dl_list_size(sfp->file_stack_) );
     683                 : }
     684               1 : END_TEST
     685                 : /* ------------------------------------------------------------------------- */
     686               1 : START_TEST(test_mfp_pop_from_file_stack)
     687                 : {
     688               1 :         MinFileParser* sfp = INITPTR;
     689               1 :         mfp_pop_from_file_stack( sfp );
     690                 : }
     691               1 : END_TEST
     692                 : /* ------------------------------------------------------------------------- */
     693               1 : START_TEST(test_mfp_pop_from_file_stack2)
     694                 : {
     695               1 :         FILE           * fp     = fopen("min.cfg","r");
     696               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     697               1 :         mfp_pop_from_file_stack( sfp );
     698                 : }
     699               1 : END_TEST
     700                 : /* ------------------------------------------------------------------------- */
     701               1 : START_TEST(test_mfp_pop_from_file_stack3)
     702                 : {
     703                 :         char             path[4096];
     704                 :         char             path2[4096];
     705                 : 
     706               1 :         FILE           * fp     = fopen("min.cfg","r");
     707               1 :         FILE           * fp2    = fopen("module.cfg","r");
     708               1 :         FILE           * fp3    = fopen("file.cfg","r");
     709               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     710                 : 
     711               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     712               1 :         sprintf(path, "%s/file.cfg", getenv("PWD"));
     713                 : 
     714               1 :         dl_list_add(sfp->file_names_,path);
     715               1 :         dl_list_add(sfp->file_stack_,fp2);
     716                 : 
     717               1 :         dl_list_add(sfp->file_names_,path2);
     718               1 :         dl_list_add(sfp->file_stack_,fp3);
     719                 : 
     720               1 :         mfp_pop_from_file_stack( sfp );
     721                 : 
     722               1 :         fail_unless( dl_list_size(sfp->file_stack_) == 1
     723                 :                    , "sfp->file_stack_ size not decreased after popping [%d]"
     724                 :                    , dl_list_size(sfp->file_stack_) );
     725                 : }
     726               1 : END_TEST
     727                 : /* ------------------------------------------------------------------------- */
     728               1 : START_TEST(test_mfp_pop_from_file_stack4)
     729                 : {
     730                 :         char             path[4096];
     731                 :         char             path2[4096];
     732                 : 
     733               1 :         FILE           * fp     = fopen("min.cfg","r");
     734               1 :         FILE           * fp2    = fopen("module.cfg","r");
     735               1 :         FILE           * fp3    = fopen("file.cfg","r");
     736               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     737               1 :         int              val    = 0;
     738                 : 
     739               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     740               1 :         sprintf(path2, "%s/file.cfg", getenv("PWD"));
     741                 : 
     742               1 :         dl_list_add(sfp->file_names_,path);
     743               1 :         dl_list_add(sfp->file_stack_,fp2);
     744                 : 
     745               1 :         dl_list_add(sfp->file_names_,path2);
     746               1 :         dl_list_add(sfp->file_stack_,fp3);
     747                 : 
     748               1 :         val = dl_list_size(sfp->file_names_);
     749                 : 
     750               1 :         mfp_pop_from_file_stack( sfp );
     751                 : 
     752               1 :         fail_unless( dl_list_size(sfp->file_names_) == (val-1)
     753                 :                    , "sfp->file_names_ size not decreased after popping [%d]"
     754                 :                    , dl_list_size(sfp->file_names_) );
     755                 : }
     756               1 : END_TEST
     757                 : /* ------------------------------------------------------------------------- */
     758               1 : START_TEST(test_mfp_pop_from_file_stack5)
     759                 : {
     760                 :         char             path[4096];
     761               1 :         FILE           * fp     = fopen("min.cfg","r");
     762               1 :         FILE           * fp2    = fopen("module.cfg","r");
     763               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     764               1 :         int              val    = 0;
     765                 : 
     766               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     767                 : 
     768               1 :         dl_list_add(sfp->file_names_,path);
     769               1 :         dl_list_add(sfp->file_stack_,fp2);
     770                 : 
     771               1 :         val = dl_list_size(sfp->file_names_);
     772                 : 
     773               1 :         mfp_pop_from_file_stack( sfp );
     774                 : 
     775               1 :         fail_unless( dl_list_size(sfp->file_names_) == (val-1)
     776                 :                    , "sfp->file_names_ size not decreased after popping [%d]"
     777                 :                    , dl_list_size(sfp->file_names_) );
     778                 : }
     779               1 : END_TEST
     780                 : /* ------------------------------------------------------------------------- */
     781               1 : START_TEST(test_mfp_pop_from_file_stack6)
     782                 : {
     783                 :         char             path[4096];
     784               1 :         FILE           * fp     = fopen("min.cfg","r");
     785               1 :         FILE           * fp2    = fopen("module.cfg","r");
     786               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     787                 : 
     788               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     789                 : 
     790               1 :         dl_list_add(sfp->file_names_,path);
     791               1 :         dl_list_add(sfp->file_stack_,fp2);
     792                 : 
     793               1 :         sfp->current_file_ = INITPTR;
     794                 : 
     795               1 :         mfp_pop_from_file_stack( sfp );
     796                 : 
     797               1 :         fail_unless( sfp->current_file_ == fp
     798                 :                    , "sfp->current_file_ != fp" );
     799                 : }
     800               1 : END_TEST
     801                 : /* ------------------------------------------------------------------------- */
     802               1 : START_TEST(test_mfp_pop_from_file_stack7)
     803                 : {
     804                 :         char             path[4096];
     805               1 :         FILE           * fp     = fopen("min.cfg","r");
     806               1 :         FILE           * fp2    = fopen("module.cfg","r");
     807               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     808                 : 
     809               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     810                 : 
     811               1 :         dl_list_add(sfp->file_names_,path);
     812               1 :         dl_list_add(sfp->file_stack_,fp2);
     813                 : 
     814               1 :         sfp->current_file_ = INITPTR;
     815                 : 
     816               1 :         mfp_pop_from_file_stack( sfp );
     817                 : 
     818               1 :         fail_unless( dl_list_size(sfp->file_stack_) == dl_list_size(sfp->file_names_)-1
     819                 :                    , "file and filename stacks differs in size [%d!=%d]"
     820                 :                    , dl_list_size(sfp->file_stack_), dl_list_size(sfp->file_names_) );
     821                 : }
     822               1 : END_TEST
     823                 : /* ------------------------------------------------------------------------- */
     824               1 : START_TEST(test_mfp_push_file_to_stack)
     825                 : {
     826               1 :         MinFileParser * sfp  = INITPTR;
     827               1 :         char*            file = "module.cfg";
     828               1 :         mfp_push_file_to_stack( sfp, file );
     829                 : }
     830               1 : END_TEST
     831                 : /* ------------------------------------------------------------------------- */
     832               1 : START_TEST(test_mfp_push_file_to_stack2)
     833                 : {
     834               1 :         FILE           * fp     = fopen("min.cfg","r");
     835               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     836               1 :         char*            file   = INITPTR;
     837               1 :         mfp_push_file_to_stack( sfp, file );
     838                 : 
     839               1 :         fail_unless( dl_list_size(sfp->file_stack_) == 0
     840                 :                    , "dl_list_size(sfp->file_stack_) != 0 [%d]"
     841                 :                    , dl_list_size(sfp->file_stack_) );
     842                 : }
     843               1 : END_TEST
     844                 : /* ------------------------------------------------------------------------- */
     845               1 : START_TEST(test_mfp_push_file_to_stack3)
     846                 : {
     847                 :         char             path[4096];
     848               1 :         FILE           * fp     = fopen("min.cfg","r");
     849               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     850                 : 
     851               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     852                 : 
     853               1 :         mfp_push_file_to_stack( sfp, path );
     854                 : 
     855               1 :         fail_unless( sfp->current_file_ != fp
     856                 :                    , "Current file has wrong value" );
     857                 : }
     858               1 : END_TEST
     859                 : /* ------------------------------------------------------------------------- */
     860               1 : START_TEST(test_mfp_push_file_to_stack4)
     861                 : {
     862                 :         char             path[4096];
     863               1 :         FILE           * fp     = fopen("min.cfg","r");
     864               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     865               1 :         int              val    = dl_list_size(sfp->file_stack_);
     866                 : 
     867               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     868                 : 
     869               1 :         dl_list_add( sfp->file_names_, path );
     870                 : 
     871               1 :         mfp_push_file_to_stack( sfp, path );
     872                 : 
     873               1 :         fail_unless( dl_list_size(sfp->file_stack_) == val
     874                 :                    , "Inproper size of file stack [%d]"
     875                 :                    , dl_list_size(sfp->file_stack_) );
     876                 : }
     877               1 : END_TEST
     878                 : /* ------------------------------------------------------------------------- */
     879               1 : START_TEST(test_mfp_push_file_to_stack5)
     880                 : {
     881                 :         char             path[4096];
     882               1 :         FILE           * fp     = fopen("min.cfg","r");
     883               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     884               1 :         int              val    = dl_list_size(sfp->file_stack_);
     885                 : 
     886               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     887                 : 
     888               1 :         mfp_push_file_to_stack( sfp, path );
     889                 : 
     890               1 :         fail_unless( dl_list_size(sfp->file_stack_) == val+1
     891                 :                    , "Inproper size of file stack [%d]"
     892                 :                    , dl_list_size(sfp->file_stack_) );
     893                 : }
     894               1 : END_TEST
     895                 : /* ------------------------------------------------------------------------- */
     896               1 : START_TEST(test_mfp_push_file_to_stack6)
     897                 : {
     898                 :         char             path[4096];
     899               1 :         FILE           * fp     = fopen("min.cfg","r");
     900               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     901               1 :         int              val    = dl_list_size(sfp->file_stack_);
     902                 : 
     903               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     904                 : 
     905               1 :         mfp_push_file_to_stack( sfp, path );
     906                 : 
     907               1 :         fail_unless( dl_list_size(sfp->file_stack_) == dl_list_size(sfp->file_names_)-1
     908                 :                    , "file and filename stacks differs in size [%d!=%d]"
     909                 :                    , dl_list_size(sfp->file_stack_), dl_list_size(sfp->file_names_) );
     910                 : }
     911               1 : END_TEST
     912                 : /* ------------------------------------------------------------------------- */
     913               1 : START_TEST(test_mfp_push_file_to_stack7)
     914                 : {
     915                 :         char             path[4096];
     916               1 :         FILE           * fp     = fopen("min.cfg","r");
     917               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     918               1 :         int              val    = dl_list_size(sfp->file_stack_);
     919                 : 
     920               1 :         sprintf(path, "%s/module.cfg", getenv("PWD"));
     921                 : 
     922               1 :         mfp_push_file_to_stack( sfp, path );
     923                 : 
     924               1 :         fail_unless( sfp->current_file_ != fp
     925                 :                    , "Current file has wrong value" );
     926                 : }
     927               1 : END_TEST
     928                 : /* ------------------------------------------------------------------------- */
     929               1 : START_TEST(test_mfp_push_file_to_stack8)
     930                 : {
     931               1 :         char             path[] = "/home/maemo/work/min/debug/tests/bla.cfg";
     932               1 :         FILE           * fp     = fopen("min.cfg","r");
     933               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     934               1 :         int              val    = dl_list_size(sfp->file_stack_);
     935                 : 
     936               1 :         mfp_push_file_to_stack( sfp, path );
     937                 : 
     938               1 :         fail_unless( dl_list_size(sfp->file_stack_) == val
     939                 :                    , "Inproper size of file stack [%d]"
     940                 :                    , dl_list_size(sfp->file_stack_) );
     941                 : }
     942               1 : END_TEST
     943                 : /* ------------------------------------------------------------------------- */
     944               1 : START_TEST(test_mfp_push_file_to_stack9)
     945                 : {
     946               1 :         char             path[] = "/home/maemo/work/min/debug/tests/bla.cfg";
     947               1 :         FILE           * fp     = fopen("min.cfg","r");
     948               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     949               1 :         int              val    = dl_list_size(sfp->file_stack_);
     950                 : 
     951               1 :         mfp_push_file_to_stack( sfp, path );
     952                 : 
     953               1 :         fail_unless( sfp->current_file_ == fp
     954                 :                    , "Current file has wrong value" );
     955                 : }
     956               1 : END_TEST
     957                 : /* ------------------------------------------------------------------------- */
     958               1 : START_TEST(test_mfp_push_file_to_stack10)
     959                 : {
     960               1 :         char             path[] = "/home/maemo/work/min/debug/tests/bla.cfg";
     961               1 :         FILE           * fp     = fopen("min.cfg","r");
     962               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     963               1 :         int              val    = dl_list_size(sfp->file_stack_);
     964                 : 
     965               1 :         mfp_push_file_to_stack( sfp, path );
     966                 : 
     967               1 :         fail_unless( dl_list_size(sfp->file_stack_) == dl_list_size(sfp->file_names_)-1
     968                 :                    , "file and filename stacks differs in size [%d!=%d]"
     969                 :                    , dl_list_size(sfp->file_stack_), dl_list_size(sfp->file_names_) );
     970                 : }
     971               1 : END_TEST
     972                 : /* ------------------------------------------------------------------------- */
     973               1 : START_TEST(test_mfp_next_section)
     974                 : {
     975               1 :         MinFileParser * sfp    = INITPTR;
     976               1 :         char           * sect   = INITPTR;
     977               1 :         int              offset = 0;
     978                 : 
     979               1 :         sect = mfp_next_section( sfp
     980                 :                                , "[Engine_Defaults]"
     981                 :                                , "[End_Defaults]"
     982                 :                                , &offset , 1 );
     983                 : 
     984               1 :         fail_unless( sect == INITPTR
     985                 :                    , "Return value difers from expected (!= INITPTR)" );
     986                 : }
     987               1 : END_TEST
     988                 : /* ------------------------------------------------------------------------- */
     989               1 : START_TEST(test_mfp_next_section2)
     990                 : {
     991               1 :         FILE           * fp     = fopen("min.cfg","r");
     992               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
     993               1 :         char           * sect   = INITPTR;
     994               1 :         int              offset = 0;
     995                 : 
     996               1 :         sect = mfp_next_section( sfp
     997                 :                                , INITPTR
     998                 :                                , "[End_Defaults]"
     999                 :                                , &offset , 1 );
    1000                 : 
    1001               1 :         fail_unless( sect == INITPTR
    1002                 :                    , "Return value difers from expected (!= INITPTR)" );
    1003               1 :         mfp_destroy(&sfp);
    1004               1 :         fclose(fp);
    1005                 : }
    1006               1 : END_TEST
    1007                 : /* ------------------------------------------------------------------------- */
    1008               1 : START_TEST(test_mfp_next_section3)
    1009                 : {
    1010               1 :         FILE           * fp     = fopen("min.cfg","r");
    1011               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
    1012               1 :         char           * sect   = INITPTR;
    1013               1 :         int              offset = 0;
    1014                 : 
    1015               1 :         sect = mfp_next_section( sfp
    1016                 :                                , "[Engine_Defaults]"
    1017                 :                                , INITPTR
    1018                 :                                , &offset , 1 );
    1019                 : 
    1020               1 :         fail_unless( sect == INITPTR
    1021                 :                    , "Return value difers from expected (!= INITPTR)" );
    1022               1 :         mfp_destroy(&sfp);
    1023               1 :         fclose(fp);
    1024                 : }
    1025               1 : END_TEST
    1026                 : /* ------------------------------------------------------------------------- */
    1027               1 : START_TEST(test_mfp_next_section4)
    1028                 : {
    1029               1 :         FILE           * fp     = fopen("min.cfg","r");
    1030               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
    1031               1 :         char           * sect   = INITPTR;
    1032               1 :         int              offset = -1;
    1033                 : 
    1034               1 :         sect = mfp_next_section( sfp
    1035                 :                                , "[Engine_Defaults]"
    1036                 :                                , "[End_Defaults]"
    1037                 :                                , &offset , 1 );
    1038                 : 
    1039               1 :         fail_unless( sect == INITPTR
    1040                 :                    , "Return value difers from expected (!= INITPTR)" );
    1041               1 :         mfp_destroy(&sfp);
    1042               1 :         fclose(fp);
    1043                 : }
    1044               1 : END_TEST
    1045                 : /* ------------------------------------------------------------------------- */
    1046               1 : START_TEST(test_mfp_next_section5)
    1047                 : {
    1048               1 :         FILE           * fp     = fopen("min.cfg","r");
    1049               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
    1050               1 :         char           * sect   = INITPTR;
    1051               1 :         int              offset = 0;
    1052                 : 
    1053               1 :         sect = mfp_next_section( sfp
    1054                 :                                , "[Engine_Defaults]"
    1055                 :                                , "[End_Defaults]"
    1056                 :                                , &offset , -1 );
    1057                 : 
    1058               1 :         fail_unless( sect == INITPTR
    1059                 :                    , "Return value difers from expected (!= INITPTR)" );
    1060               1 :         mfp_destroy(&sfp);
    1061               1 :         fclose(fp);
    1062                 : }
    1063               1 : END_TEST
    1064                 : /* ------------------------------------------------------------------------- */
    1065               1 : START_TEST(test_mfp_next_section6)
    1066                 : {
    1067               1 :         FILE           * fp     = fopen("min.cfg","r");
    1068               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
    1069               1 :         char           * sect   = INITPTR;
    1070               1 :         int              offset = 0;
    1071                 : 
    1072               1 :         sect = mfp_next_section( sfp
    1073                 :                                , "[Engine_Defaults]"
    1074                 :                                , "[End_Defaults]"
    1075                 :                                , &offset , 0 );
    1076                 : 
    1077               1 :         fail_unless( sect == INITPTR
    1078                 :                    , "Return value difers from expected (!= INITPTR)" );
    1079               1 :         mfp_destroy(&sfp);
    1080               1 :         fclose(fp);
    1081                 : }
    1082               1 : END_TEST
    1083                 : /* ------------------------------------------------------------------------- */
    1084               1 : START_TEST(test_mfp_next_section7)
    1085                 : {
    1086               1 :         FILE           * fp     = fopen("min.cfg","r");
    1087               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
    1088               1 :         char           * sect   = INITPTR;
    1089               1 :         int              offset = 0;
    1090                 : 
    1091               1 :         sect = mfp_next_section( sfp
    1092                 :                                , "[Engine_Defaults]"
    1093                 :                                , "[End_Defaults]"
    1094                 :                                , &offset , 1 );
    1095                 : 
    1096               1 :         fail_unless( sect != INITPTR
    1097                 :                    , "Return value difers from expected (== INITPTR)" );
    1098                 : 
    1099               1 :         free(sect);
    1100               1 :         mfp_destroy(&sfp);
    1101               1 :         fclose(fp);
    1102                 : }
    1103               1 : END_TEST
    1104                 : /* ------------------------------------------------------------------------- */
    1105               1 : START_TEST(test_mfp_next_section8)
    1106                 : {
    1107               1 :         FILE           * fp     = fopen("module.cfg","r");
    1108               1 :         MinFileParser * sfp    = mfp_create(fp,EFileNotUnicode,ENoComments);
    1109               1 :         char           * sect   = INITPTR;
    1110               1 :         char           * exp    = "ModuleName= demomodule\n";
    1111               1 :         int              offset = 0;
    1112                 : 
    1113               1 :         sect = mfp_next_section( sfp
    1114                 :                                , "[New_Module]"
    1115                 :                                , "[End_Module]"
    1116                 :                                , &offset , 5 );
    1117                 : 
    1118               1 :         fail_unless( sect == INITPTR
    1119                 :                    , "sect != INITPTR" );
    1120                 : 
    1121               1 :         mfp_destroy(&sfp);
    1122               1 :         fclose(fp);
    1123                 : }
    1124               1 : END_TEST
    1125                 : /* ------------------------------------------------------------------------- */
    1126                 : /* ========================== FUNCTIONS ==================================== */
    1127                 : /* ------------------------------------------------------------------------- */
    1128                 : Suite* min_file_parser_suite()
    1129             342 : {
    1130             342 :         Suite * s = suite_create ("min_file_parser");
    1131                 : 
    1132                 :         /* Core test case */
    1133             342 :         TCase *tc_core = tcase_create ("Core");
    1134                 : 
    1135                 :         /* mfp_create */
    1136             342 :         tcase_add_test (tc_core, test_mfp_create);
    1137             342 :         tcase_add_test (tc_core, test_mfp_create2);
    1138             342 :         tcase_add_test (tc_core, test_mfp_create3);
    1139             342 :         tcase_add_test (tc_core, test_mfp_create4);
    1140             342 :         tcase_add_test (tc_core, test_mfp_create5);
    1141             342 :         tcase_add_test (tc_core, test_mfp_create6);
    1142             342 :         tcase_add_test (tc_core, test_mfp_create7);
    1143             342 :         tcase_add_test (tc_core, test_mfp_create8);
    1144             342 :         tcase_add_test (tc_core, test_mfp_create9);
    1145             342 :         tcase_add_test (tc_core, test_mfp_create10);
    1146             342 :         tcase_add_test (tc_core, test_mfp_create11);
    1147             342 :         tcase_add_test (tc_core, test_mfp_create12);
    1148                 : 
    1149                 :         /* mfp_destroy */
    1150             342 :         tcase_add_test (tc_core, test_mfp_destroy);
    1151             342 :         tcase_add_test (tc_core, test_mfp_destroy2);
    1152                 : 
    1153                 :         /* mfp_read_line */
    1154             342 :         tcase_add_test (tc_core, test_mfp_read_line);
    1155             342 :         tcase_add_test (tc_core, test_mfp_read_line2);
    1156             342 :         tcase_add_test (tc_core, test_mfp_read_line3);
    1157             342 :         tcase_add_test (tc_core, test_mfp_read_line4);
    1158             342 :         tcase_add_test (tc_core, test_mfp_read_line5);
    1159             342 :         tcase_add_test (tc_core, test_mfp_read_line6);
    1160             342 :         tcase_add_test (tc_core, test_mfp_read_line7);
    1161             342 :         tcase_add_test (tc_core, test_mfp_read_line8);
    1162                 : 
    1163                 :         /* mfp_replace_comments_line */
    1164             342 :         tcase_add_test (tc_core, test_mfp_replace_comments_line);
    1165             342 :         tcase_add_test (tc_core, test_mfp_replace_comments_line2);
    1166             342 :         tcase_add_test (tc_core, test_mfp_replace_comments_line3);
    1167             342 :         tcase_add_test (tc_core, test_mfp_replace_comments_line4);
    1168             342 :         tcase_add_test (tc_core, test_mfp_replace_comments_line5);
    1169             342 :         tcase_add_test (tc_core, test_mfp_replace_comments_line6);
    1170             342 :         tcase_add_test (tc_core, test_mfp_replace_comments_line7);
    1171                 : 
    1172                 :         /* mfp_replace_hash_comments_line */
    1173             342 :         tcase_add_test (tc_core, test_mfp_replace_hash_comments_line);
    1174             342 :         tcase_add_test (tc_core, test_mfp_replace_hash_comments_line2);
    1175             342 :         tcase_add_test (tc_core, test_mfp_replace_hash_comments_line3);
    1176             342 :         tcase_add_test (tc_core, test_mfp_replace_hash_comments_line4);
    1177             342 :         tcase_add_test (tc_core, test_mfp_replace_hash_comments_line5);
    1178             342 :         tcase_add_test (tc_core, test_mfp_replace_hash_comments_line6);
    1179             342 :         tcase_add_test (tc_core, test_mfp_replace_hash_comments_line7);
    1180                 : 
    1181                 :         /* mfp_clear_file_stack */
    1182             342 :         tcase_add_test (tc_core, test_mfp_clear_file_stack);
    1183             342 :         tcase_add_test (tc_core, test_mfp_clear_file_stack2);
    1184             342 :         tcase_add_test (tc_core, test_mfp_clear_file_stack3);
    1185             342 :         tcase_add_test (tc_core, test_mfp_clear_file_stack4);
    1186                 : 
    1187                 :         /* mfp_pop_from_file_stack */
    1188             342 :         tcase_add_test (tc_core, test_mfp_pop_from_file_stack);
    1189             342 :         tcase_add_test (tc_core, test_mfp_pop_from_file_stack2);
    1190             342 :         tcase_add_test (tc_core, test_mfp_pop_from_file_stack3);
    1191             342 :         tcase_add_test (tc_core, test_mfp_pop_from_file_stack4);
    1192             342 :         tcase_add_test (tc_core, test_mfp_pop_from_file_stack5);
    1193             342 :         tcase_add_test (tc_core, test_mfp_pop_from_file_stack6);
    1194             342 :         tcase_add_test (tc_core, test_mfp_pop_from_file_stack7);
    1195                 : 
    1196                 :         /* mfp_push_file_to_stack */
    1197             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack);
    1198             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack2);
    1199             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack3);
    1200             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack4);
    1201             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack5);
    1202             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack6);
    1203             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack7);
    1204             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack8);
    1205             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack9);
    1206             342 :         tcase_add_test (tc_core, test_mfp_push_file_to_stack10);
    1207                 : 
    1208                 :         /* mfp_next_section */
    1209             342 :         tcase_add_test (tc_core, test_mfp_next_section);
    1210             342 :         tcase_add_test (tc_core, test_mfp_next_section2);
    1211             342 :         tcase_add_test (tc_core, test_mfp_next_section3);
    1212             342 :         tcase_add_test (tc_core, test_mfp_next_section4);
    1213             342 :         tcase_add_test (tc_core, test_mfp_next_section5);
    1214             342 :         tcase_add_test (tc_core, test_mfp_next_section6);
    1215             342 :         tcase_add_test (tc_core, test_mfp_next_section7);
    1216             342 :         tcase_add_test (tc_core, test_mfp_next_section8);
    1217                 : 
    1218             342 :         suite_add_tcase (s, tc_core);
    1219                 : 
    1220             342 :         return s;
    1221                 : }
    1222                 : /* ------------------------------------------------------------------------- */
    1223                 : int min_file_parser_tests()
    1224             342 : {
    1225             342 :         int number_failed = 0;
    1226             342 :         Suite   * s  = min_file_parser_suite ();
    1227             342 :         SRunner * sr = srunner_create (s);
    1228                 : 
    1229                 :         /* srunner_set_fork_status (sr, CK_NOFORK); */
    1230                 : 
    1231             342 :         srunner_run_all(sr, CK_NORMAL);
    1232             277 :         number_failed = srunner_ntests_failed(sr);
    1233             277 :         srunner_free(sr);
    1234             277 :         return number_failed;
    1235                 : }
    1236                 : /* ------------------------------------------------------------------------- */
    1237                 : /* End of file */

Generated by: LTP GCOV extension version 1.6