LCOV - code coverage report
Current view: top level - tests/src - test0024.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 58 58
Test Date: 2026-03-31 13:51:38 Functions: 100.0 % 4 4
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : #include "sute.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Verify traversal output when the source path starts with an apostrophe
       5                 :             :  *
       6                 :             :  * @return Return status code
       7                 :             :  */
       8                 :           2 : Return test0024_1(void)
       9                 :             : {
      10                 :           2 :         INITTEST;
      11                 :             : 
      12                 :           2 :         create(char,pattern);
      13                 :             : 
      14                 :             :         // Create memory for the result
      15                 :           2 :         create(char,result);
      16                 :             : 
      17                 :             :         /*
      18                 :             :          * Checking how paths are handled when the directory name starts
      19                 :             :          * with an apostrophe
      20                 :             :          */
      21                 :           2 :         const char *arguments = "--progress --database=database1.db "
      22                 :             :                 "tests/fixtures/\\'apostrophe";
      23                 :             : 
      24                 :           2 :         const char *filename = "templates/0024_001.txt";
      25                 :             : 
      26                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      27                 :             : 
      28                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      29                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      30                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      31                 :             : 
      32                 :             :         // Clean to use it iteratively
      33                 :           2 :         del(pattern);
      34                 :           2 :         del(result);
      35                 :             : 
      36                 :             :         // Clean up test results
      37                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      38                 :             : 
      39                 :           2 :         RETURN_STATUS;
      40                 :             : }
      41                 :             : 
      42                 :             : /**
      43                 :             :  * @brief Verify traversal output when the source path ends with an apostrophe
      44                 :             :  *
      45                 :             :  * @return Return status code
      46                 :             :  */
      47                 :           2 : Return test0024_2(void)
      48                 :             : {
      49                 :           2 :         INITTEST;
      50                 :             : 
      51                 :           2 :         create(char,pattern);
      52                 :             : 
      53                 :             :         // Create memory for the result
      54                 :           2 :         create(char,result);
      55                 :             : 
      56                 :             :         /*
      57                 :             :          * Checking how paths are handled when the directory name ends
      58                 :             :          * with an apostrophe
      59                 :             :          */
      60                 :           2 :         const char *arguments = "--progress --database=database1.db tests/fixtures/apostrophe\\'";
      61                 :             : 
      62                 :           2 :         const char *filename = "templates/0024_002.txt";
      63                 :             : 
      64                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      65                 :             : 
      66                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      67                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      68                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      69                 :             : 
      70                 :             :         // Clean to use it iteratively
      71                 :           2 :         del(pattern);
      72                 :           2 :         del(result);
      73                 :             : 
      74                 :             :         // Clean up test results
      75                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      76                 :             : 
      77                 :           2 :         RETURN_STATUS;
      78                 :             : }
      79                 :             : 
      80                 :             : /**
      81                 :             :  * Stage 1. Adding:
      82                 :             :  * precizer --progress --database=database1.db tests/fixtures/\'apostrophe/\'apostrophe/
      83                 :             :  * Stage 2. Adding:
      84                 :             :  * precizer --progress --database=database2.db tests/fixtures/apostrophe\'/\'apostrophe/apostrophe\'/
      85                 :             :  * Final stage. Comparing:
      86                 :             :  * precizer --compare database1.db database2.db
      87                 :             :  */
      88                 :           2 : static Return test0024_3(void)
      89                 :             : {
      90                 :           2 :         INITTEST;
      91                 :             : 
      92                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      93                 :             : 
      94                 :           2 :         const char *arguments = "--progress --database=database1.db "
      95                 :             :                 "tests/fixtures/\\'apostrophe/\\'apostrophe/";
      96                 :             : 
      97                 :             :         // Create memory for the result
      98                 :           2 :         create(char,result);
      99                 :           2 :         create(char,chunk);
     100                 :             : 
     101                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     102                 :             : 
     103                 :           2 :         ASSERT(SUCCESS == copy(result,chunk));
     104                 :             : 
     105                 :           2 :         arguments = "--progress --database=database2.db "
     106                 :             :                 "tests/fixtures/apostrophe\\'/\\'apostrophe/apostrophe\\'/";
     107                 :             : 
     108                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     109                 :             : 
     110                 :           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
     111                 :             : 
     112                 :           2 :         arguments = "--compare database1.db database2.db";
     113                 :             : 
     114                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     115                 :             : 
     116                 :           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
     117                 :             : 
     118                 :             :         // Create memory for the result
     119                 :           2 :         create(char,pattern);
     120                 :             : 
     121                 :           2 :         const char *filename = "templates/0024_003.txt";
     122                 :             : 
     123                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
     124                 :             : 
     125                 :             :         // Match the result against the pattern
     126                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
     127                 :             : 
     128                 :             :         // Clean up test results
     129                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
     130                 :           2 :         ASSERT(SUCCESS == delete_path("database2.db"));
     131                 :             : 
     132                 :           2 :         del(pattern);
     133                 :           2 :         del(chunk);
     134                 :           2 :         del(result);
     135                 :             : 
     136                 :           2 :         RETURN_STATUS;
     137                 :             : }
     138                 :             : 
     139                 :             : // Main test runner
     140                 :           2 : Return test0024(void)
     141                 :             : {
     142                 :           2 :         INITTEST;
     143                 :             : 
     144                 :           2 :         TEST(test0024_1,"Prefix path with apostrophe…");
     145                 :           2 :         TEST(test0024_2,"Another prefix and apostrophe combination in the name…");
     146                 :           2 :         TEST(test0024_3,"Adding and comparing with apostrophe…");
     147                 :             : 
     148                 :           2 :         RETURN_STATUS;
     149                 :             : }
        

Generated by: LCOV version 2.0-1