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

            Line data    Source code
       1              : #include "sute.h"
       2              : #include <sysexits.h>
       3              : 
       4              : /**
       5              :  *
       6              :  * Check the name of the database created by default.
       7              :  * Does it really comply with to the "hostname.db" template
       8              :  *
       9              :  */
      10            2 : Return test0003_1(void)
      11              : {
      12            2 :         INITTEST;
      13              : 
      14            2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      15              : 
      16            2 :         ASSERT(SUCCESS == runit("--progress tests/examples/diffs/diff1",NULL,COMPLETED,ALLOW_BOTH));
      17              : 
      18            2 :         ASSERT(SUCCESS == runit("--progress --database=database2.db tests/examples/diffs/diff2",NULL,COMPLETED,ALLOW_BOTH));
      19              : 
      20              :         // Get the output of the application
      21            2 :         const char *arguments = "--compare $DBNAME database2.db";
      22              : 
      23            2 :         const char *filename = "templates/0003_001.txt";  // File name
      24            2 :         const char *template = "%DB_NAME%";
      25              : 
      26            2 :         const char *replacement = getenv("DBNAME");  // Database name
      27              : 
      28            2 :         ASSERT(replacement != NULL);
      29              : 
      30            2 :         ASSERT(SUCCESS == match_app_output(arguments,filename,template,replacement,COMPLETED));
      31              : 
      32              :         // Clean up test results
      33            2 :         ASSERT(SUCCESS == external_call("rm \"${TMPDIR}/${DBNAME}\" \"${TMPDIR}/database2.db\"",COMPLETED,ALLOW_BOTH));
      34              : 
      35            2 :         RETURN_STATUS;
      36              : }
      37              : 
      38              : /**
      39              :  *
      40              :  * Running the application with no arguments at all
      41              :  *
      42              :  */
      43            2 : Return test0003_2(void)
      44              : {
      45            2 :         INITTEST;
      46              : 
      47              : #if 0
      48              :         create(char,result);
      49              :         create(char,pattern);
      50              : 
      51              :         const char *filename = "templates/0003_002.txt";
      52              : 
      53              :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      54              : 
      55              :         ASSERT(SUCCESS == runit("",result,EX_USAGE,ALLOW_BOTH));
      56              : #endif
      57              : 
      58            2 :         ASSERT(SUCCESS == runit("",NULL,EX_USAGE,STDERR_SUPPRESS));
      59              : 
      60              : #if 0
      61              :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      62              : 
      63              :         // Match the result against the pattern
      64              :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      65              : 
      66              :         // Clean to use it iteratively
      67              :         del(pattern);
      68              :         del(result);
      69              : #endif
      70              : 
      71            2 :         RETURN_STATUS;
      72              : 
      73              : }
      74              : 
      75            2 : Return test0003(void)
      76              : {
      77            2 :         INITTEST;
      78              : 
      79            2 :         TEST(test0003_1,"Comply default DB name to \"hostname.db\" template…");
      80            2 :         TEST(test0003_2,"Running the application with no arguments at all…");
      81              : 
      82            2 :         RETURN_STATUS;
      83              : }
        

Generated by: LCOV version 2.0-1