LCOV - code coverage report
Current view: top level - tests/src - test0024.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 57 57
Test Date: 2026-01-12 05:34:38 Functions: 100.0 % 4 4

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

Generated by: LCOV version 2.0-1