Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/configs/usage.cfa

    r0b6089f r9e042d8  
    1010// Author           : Thierry Delisle
    1111// Created On       : Wed Oct 12 15:28:01 2022
    12 // Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sun Feb 11 09:29:51 2024
    14 // Update Count     : 1
     12// Last Modified By :
     13// Last Modified On :
     14// Update Count     :
    1515//
    1616
     
    2424
    2525        sout | "No args, no errors";
    26         if ( pid_t child = strict_fork(); child == 0 ) {
     26        if(pid_t child = strict_fork(); child == 0) {
    2727                array( cfa_option, 0 ) opts;
    28                 print_args_usage(1, fake_argv, opts, "Test usage", false );
    29         } else {
    30                 int status = do_wait( child );
    31                 print_status( status );
    32         } // if
     28                print_args_usage(1, fake_argv, opts, "Test usage", false);
     29        }
     30        else {
     31                int status = do_wait(child);
     32                print_status(status);
     33        }
    3334
    3435        sout | "No args, with errors";
    35         if ( pid_t child = strict_fork(); child == 0 ) {
     36        if(pid_t child = strict_fork(); child == 0) {
    3637                array( cfa_option, 0 ) opts;
    37                 print_args_usage(1, fake_argv, opts, "Test usage", true );
    38         } else {
    39                 int status = do_wait( child );
    40                 print_status( status );
    41         } // if
     38                print_args_usage(1, fake_argv, opts, "Test usage", true);
     39        }
     40        else {
     41                int status = do_wait(child);
     42                print_status(status);
     43        }
    4244
    4345        sout | "Args with short names only:";
    44         if ( pid_t child = strict_fork(); child == 0 ) {
     46        if(pid_t child = strict_fork(); child == 0) {
    4547                int a, b, c;
    4648                array( cfa_option, 3 ) opts;
     
    4850                opts[1] = (cfa_option){'b', "", "Second arg", b };
    4951                opts[2] = (cfa_option){'c', "", "Third arg", c };
    50                 print_args_usage(1, fake_argv, opts, "Test usage", false );
    51         } else {
    52                 int status = do_wait( child );
    53                 print_status( status );
    54         } // if
     52                print_args_usage(1, fake_argv, opts, "Test usage", false);
     53        }
     54        else {
     55                int status = do_wait(child);
     56                print_status(status);
     57        }
    5558
    5659        sout | "Args with long names only:";
    57         if ( pid_t child = strict_fork(); child == 0 ) {
     60        if(pid_t child = strict_fork(); child == 0) {
    5861                int a, b, c;
    5962                array( cfa_option, 3 ) opts;
     
    6164                opts[1] = (cfa_option){'\0', "BB", "Second arg", b };
    6265                opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    63                 print_args_usage(1, fake_argv, opts, "Test usage", false );
    64         } else {
    65                 int status = do_wait( child );
    66                 print_status( status );
    67         } // if
     66                print_args_usage(1, fake_argv, opts, "Test usage", false);
     67        }
     68        else {
     69                int status = do_wait(child);
     70                print_status(status);
     71        }
    6872
    6973        sout | "Mix of short and long args:";
    70         if ( pid_t child = strict_fork(); child == 0 ) {
     74        if(pid_t child = strict_fork(); child == 0) {
    7175                int a, b, c;
    7276                array( cfa_option, 3 ) opts;
     
    7478                opts[1] = (cfa_option){'b', "BBBB", "Second arg", b };
    7579                opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    76                 print_args_usage(1, fake_argv, opts, "Test usage", false );
    77         } else {
    78                 int status = do_wait( child );
    79                 print_status( status );
    80         } // if
     80                print_args_usage(1, fake_argv, opts, "Test usage", false);
     81        }
     82        else {
     83                int status = do_wait(child);
     84                print_status(status);
     85        }
    8186
    8287        sout | "Mix of short and long and some missing description:";
    83         if ( pid_t child = strict_fork(); child == 0 ) {
     88        if(pid_t child = strict_fork(); child == 0) {
    8489                int a, b, c;
    8590                array( cfa_option, 3 ) opts;
     
    8792                opts[1] = (cfa_option){'b', "BBBB", "", b };
    8893                opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    89                 print_args_usage(1, fake_argv, opts, "Test usage", false );
    90         } else {
    91                 int status = do_wait( child );
    92                 print_status( status );
    93         } // if
     94                print_args_usage(1, fake_argv, opts, "Test usage", false);
     95        }
     96        else {
     97                int status = do_wait(child);
     98                print_status(status);
     99        }
    94100
    95101        sout | "Mix of short and long and some long description:";
    96         if ( pid_t child = strict_fork(); child == 0 ) {
     102        if(pid_t child = strict_fork(); child == 0) {
    97103                int a, b, c;
    98104                array( cfa_option, 3 ) opts;
     
    100106                opts[1] = (cfa_option){'b', "BBBB", "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", b };
    101107                opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    102                 print_args_usage(1, fake_argv, opts, "Test usage", false );
    103         } else {
    104                 int status = do_wait( child );
    105                 print_status( status );
    106         } // if
     108                print_args_usage(1, fake_argv, opts, "Test usage", false);
     109        }
     110        else {
     111                int status = do_wait(child);
     112                print_status(status);
     113        }
    107114}
    108115
    109116// no used
    110 static int true_main( const char * path, char * env[]) { return 0; }
     117static int true_main(const char * path, char * env[]) { return 0; }
Note: See TracChangeset for help on using the changeset viewer.