LCOV - code coverage report
Current view: top level - tests/src - test0024.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 53 53
Test Date: 2026-10-20 14:27:43 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                 :             :  * CLI and configuration runs enable progress and use the same full output
       7                 :             :  * template, including the initial file count. Each run starts without a database
       8                 :             :  *
       9                 :             :  * @return Return status code
      10                 :             :  */
      11                 :           2 : Return test0024_1(void)
      12                 :             : {
      13                 :           2 :         INITTEST;
      14                 :             : 
      15                 :             :         /*
      16                 :             :          * Checking how paths are handled when the directory name starts
      17                 :             :          * with an apostrophe
      18                 :             :          */
      19                 :           2 :         const char *arguments = "--progress --database=database1.db "
      20                 :             :                 "tests/fixtures/\\'apostrophe";
      21                 :             : 
      22                 :           2 :         const char *filename = "templates/0024_001.txt";
      23                 :             : 
      24                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      25                 :             : 
      26                 :           2 :         const struct argument_test_case cases[] = {
      27                 :             :                 {arguments,COMPLETED,filename,STDERR_MUST_BE_EMPTY},
      28                 :             :                 {0}
      29                 :             :         };
      30                 :             : 
      31                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
      32                 :             : 
      33                 :             :         // Clean up test results
      34                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      35                 :             : 
      36                 :             :         /* Repeat the scan through configuration with the literal apostrophe in the path */
      37                 :           2 :         ASSERT(SUCCESS == copy_path("tests/templates/0024_001.conf","0024_001.conf"));
      38                 :           2 :         const struct argument_test_case file_cases[] = {
      39                 :             :                 {"--config=0024_001.conf",COMPLETED,filename,STDERR_MUST_BE_EMPTY},
      40                 :             :                 {0}
      41                 :             :         };
      42                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(file_cases,NULL,NULL));
      43                 :           2 :         call(delete_path_if_present("0024_001.conf"));
      44                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      45                 :             : 
      46                 :           2 :         RETURN_STATUS;
      47                 :             : }
      48                 :             : 
      49                 :             : /**
      50                 :             :  * @brief Verify traversal output when the source path ends with an apostrophe
      51                 :             :  *
      52                 :             :  * @return Return status code
      53                 :             :  */
      54                 :           2 : Return test0024_2(void)
      55                 :             : {
      56                 :           2 :         INITTEST;
      57                 :             : 
      58                 :             :         /*
      59                 :             :          * Checking how paths are handled when the directory name ends
      60                 :             :          * with an apostrophe
      61                 :             :          */
      62                 :           2 :         const char *arguments = "--progress --database=database1.db tests/fixtures/apostrophe\\'";
      63                 :             : 
      64                 :           2 :         const char *filename = "templates/0024_002.txt";
      65                 :             : 
      66                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      67                 :             : 
      68                 :           2 :         const struct argument_test_case cases[] = {
      69                 :             :                 {arguments,COMPLETED,filename,STDERR_MUST_BE_EMPTY},
      70                 :             :                 {0}
      71                 :             :         };
      72                 :             : 
      73                 :           2 :         ASSERT(SUCCESS == run_and_match_templates(cases,NULL,NULL));
      74                 :             : 
      75                 :             :         // Clean up test results
      76                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      77                 :             : 
      78                 :           2 :         RETURN_STATUS;
      79                 :             : }
      80                 :             : 
      81                 :             : /**
      82                 :             :  * Stage 1. Adding:
      83                 :             :  * precizer --progress --database=database1.db tests/fixtures/\'apostrophe/\'apostrophe/
      84                 :             :  * Stage 2. Adding:
      85                 :             :  * precizer --progress --database=database2.db tests/fixtures/apostrophe\'/\'apostrophe/apostrophe\'/
      86                 :             :  * Final stage. Comparing:
      87                 :             :  * precizer --compare --check-level=QUICK database1.db database2.db
      88                 :             :  */
      89                 :           2 : static Return test0024_3(void)
      90                 :             : {
      91                 :           2 :         INITTEST;
      92                 :             : 
      93                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      94                 :             : 
      95                 :           2 :         const char *arguments = "--progress --database=database1.db "
      96                 :             :                 "tests/fixtures/\\'apostrophe/\\'apostrophe/";
      97                 :             : 
      98                 :             :         // Create memory for the result
      99                 :           2 :         m_create(char,result,MEMORY_STRING);
     100                 :           2 :         m_create(char,chunk,MEMORY_STRING);
     101                 :             : 
     102                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     103                 :             : 
     104                 :           2 :         ASSERT(SUCCESS == m_copy(result,chunk));
     105                 :             : 
     106                 :           2 :         arguments = "--progress --database=database2.db "
     107                 :             :                 "tests/fixtures/apostrophe\\'/\\'apostrophe/apostrophe\\'/";
     108                 :             : 
     109                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     110                 :             : 
     111                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
     112                 :             : 
     113                 :           2 :         arguments = "--compare --check-level=QUICK database1.db database2.db";
     114                 :             : 
     115                 :           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     116                 :             : 
     117                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
     118                 :             : 
     119                 :             :         // Create memory for the result
     120                 :           2 :         m_create(char,pattern,MEMORY_STRING);
     121                 :             : 
     122                 :           2 :         const char *filename = "templates/0024_003.txt";
     123                 :             : 
     124                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
     125                 :             : 
     126                 :             :         // Match the result against the pattern
     127                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
     128                 :             : 
     129                 :             :         // Clean up test results
     130                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
     131                 :           2 :         ASSERT(SUCCESS == delete_path("database2.db"));
     132                 :             : 
     133                 :           2 :         m_del(pattern);
     134                 :           2 :         m_del(chunk);
     135                 :           2 :         m_del(result);
     136                 :             : 
     137                 :           2 :         RETURN_STATUS;
     138                 :             : }
     139                 :             : 
     140                 :             : // Main test runner
     141                 :           2 : Return test0024(void)
     142                 :             : {
     143                 :           2 :         INITTEST;
     144                 :             : 
     145                 :           2 :         TEST(test0024_1,"Prefix path with apostrophe");
     146                 :           2 :         TEST(test0024_2,"Another prefix and apostrophe combination in the name");
     147                 :           2 :         TEST(test0024_3,"Adding and comparing with apostrophe");
     148                 :             : 
     149                 :           2 :         RETURN_STATUS;
     150                 :             : }
        

Generated by: LCOV version 2.0-1