Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/configs/usage.cfa

    r9e042d8 rf82f07e  
    1515//
    1616
     17#include <parseargs.hfa>
    1718#include <fstream.hfa>
     19
    1820#include "../meta/fork+exec.hfa"
    19 #include <parseargs.hfa>
    20 
    2121
    2222int main() {
     
    2525        sout | "No args, no errors";
    2626        if(pid_t child = strict_fork(); child == 0) {
    27                 array( cfa_option, 0 ) opts;
    28                 print_args_usage(1, fake_argv, opts, "Test usage", false);
     27                cfa_option opts[0];
     28                print_args_usage(1, fake_argv, opts, 0, "Test usage", false);
    2929        }
    3030        else {
     
    3535        sout | "No args, with errors";
    3636        if(pid_t child = strict_fork(); child == 0) {
    37                 array( cfa_option, 0 ) opts;
    38                 print_args_usage(1, fake_argv, opts, "Test usage", true);
     37                cfa_option opts[0];
     38                print_args_usage(1, fake_argv, opts, 0, "Test usage", true);
    3939        }
    4040        else {
     
    4646        if(pid_t child = strict_fork(); child == 0) {
    4747                int a, b, c;
    48                 array( cfa_option, 3 ) opts;
    49                 opts[0] = (cfa_option){'a', "", "First arg", a };
    50                 opts[1] = (cfa_option){'b', "", "Second arg", b };
    51                 opts[2] = (cfa_option){'c', "", "Third arg", c };
    52                 print_args_usage(1, fake_argv, opts, "Test usage", false);
     48                cfa_option opts[] = {
     49                        {'a', "", "First arg", a },
     50                        {'b', "", "Second arg", b },
     51                        {'c', "", "Third arg", c },
     52                };
     53                print_args_usage(1, fake_argv, opts, 3, "Test usage", false);
    5354        }
    5455        else {
     
    6061        if(pid_t child = strict_fork(); child == 0) {
    6162                int a, b, c;
    62                 array( cfa_option, 3 ) opts;
    63                 opts[0] = (cfa_option){'\0', "AA", "First arg", a };
    64                 opts[1] = (cfa_option){'\0', "BB", "Second arg", b };
    65                 opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    66                 print_args_usage(1, fake_argv, opts, "Test usage", false);
     63                cfa_option opts[] = {
     64                        {'\0', "AA", "First arg", a },
     65                        {'\0', "BB", "Second arg", b },
     66                        {'\0', "CC", "Third arg", c },
     67                };
     68                print_args_usage(1, fake_argv, opts, 3, "Test usage", false);
    6769        }
    6870        else {
     
    7476        if(pid_t child = strict_fork(); child == 0) {
    7577                int a, b, c;
    76                 array( cfa_option, 3 ) opts;
    77                 opts[0] = (cfa_option){'a', "", "First arg", a };
    78                 opts[1] = (cfa_option){'b', "BBBB", "Second arg", b };
    79                 opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    80                 print_args_usage(1, fake_argv, opts, "Test usage", false);
     78                cfa_option opts[] = {
     79                        {'a', "", "First arg", a },
     80                        {'b', "BBBB", "Second arg", b },
     81                        {'\0', "CC", "Third arg", c },
     82                };
     83                print_args_usage(1, fake_argv, opts, 3, "Test usage", false);
    8184        }
    8285        else {
     
    8891        if(pid_t child = strict_fork(); child == 0) {
    8992                int a, b, c;
    90                 array( cfa_option, 3 ) opts;
    91                 opts[0] = (cfa_option){'a', "", "First arg", a };
    92                 opts[1] = (cfa_option){'b', "BBBB", "", b };
    93                 opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    94                 print_args_usage(1, fake_argv, opts, "Test usage", false);
     93                cfa_option opts[] = {
     94                        {'a', "", "First arg", a },
     95                        {'b', "BBBB", "", b },
     96                        {'\0', "CC", "Third arg", c },
     97                };
     98                print_args_usage(1, fake_argv, opts, 3, "Test usage", false);
    9599        }
    96100        else {
     
    102106        if(pid_t child = strict_fork(); child == 0) {
    103107                int a, b, c;
    104                 array( cfa_option, 3 ) opts;
    105                 opts[0] = (cfa_option){'a', "", "First arg\nThe description has multiple lines,\n...for some reason", a };
    106                 opts[1] = (cfa_option){'b', "BBBB", "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", b };
    107                 opts[2] = (cfa_option){'\0', "CC", "Third arg", c };
    108                 print_args_usage(1, fake_argv, opts, "Test usage", false);
     108                cfa_option opts[] = {
     109                        {'a', "", "First arg\nThe description has multiple lines,\n...for some reason", a },
     110                        {'b', "BBBB", "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", b },
     111                        {'\0', "CC", "Third arg", c },
     112                };
     113                print_args_usage(1, fake_argv, opts, 3, "Test usage", false);
    109114        }
    110115        else {
Note: See TracChangeset for help on using the changeset viewer.