- Timestamp:
- Oct 19, 2022, 4:33:34 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 135143b
- Parents:
- 72b5805e
- Location:
- tests/configs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/configs/parsebools.cfa
r72b5805e rd1abc63c 15 15 // 16 16 17 #include <fstream.hfa> 17 18 #include <parseargs.hfa> 18 #include <fstream.hfa>19 19 20 20 #include "../meta/fork+exec.hfa" … … 30 30 bool sf = true; 31 31 32 cfa_option options[] = { 33 {'e', "yesno", "test yes/no", YN, parse_yesno}, 34 {'y', "YN", "test yes/no", Yn, parse_yesno}, 35 {'n', "yn", "test yes/no", yn, parse_yesno}, 36 {'t', "truefalse", "test true/false", tf, parse_truefalse}, 37 {'s', "settrue", "test set true", st, parse_settrue}, 38 {'u', "setfalse", "test set false", sf, parse_setfalse}, 39 }; 40 int options_cnt = sizeof(options) / sizeof(cfa_option); 32 array( cfa_option, 6 ) options; 33 options[0] = (cfa_option){'e', "yesno", "test yes/no", YN, parse_yesno}; 34 options[1] = (cfa_option){'y', "YN", "test yes/no", Yn, parse_yesno}; 35 options[2] = (cfa_option){'n', "yn", "test yes/no", yn, parse_yesno}; 36 options[3] = (cfa_option){'t', "truefalse", "test true/false", tf, parse_truefalse}; 37 options[4] = (cfa_option){'s', "settrue", "test set true", st, parse_settrue}; 38 options[5] = (cfa_option){'u', "setfalse", "test set false", sf, parse_setfalse}; 41 39 42 40 char **left; 43 parse_args( options, options_cnt,"[OPTIONS]...\ntesting bool parameters", left);41 parse_args( options, "[OPTIONS]...\ntesting bool parameters", left); 44 42 45 43 sout | "yes/no :" | YN; -
tests/configs/parsenums.cfa
r72b5805e rd1abc63c 15 15 // 16 16 17 #include <fstream.hfa> 17 18 #include <parseargs.hfa> 18 #include <fstream.hfa>19 19 20 20 #include "../meta/fork+exec.hfa" … … 42 42 43 43 44 cfa_option options[] = { 45 { 'i', "int", "test int", i }, 46 { 'u', "unsigned", "test unsigned", u }, 47 { 'l', "unsignedlong", "test unsigned long", ul }, 48 { 'L', "unsignedlonglong", "test unsigned long long", ull }, 49 { 'd', "double", "test double", d }, 50 }; 51 int options_cnt = sizeof(options) / sizeof(cfa_option); 44 array( cfa_option, 5 ) options; 45 options[0] = (cfa_option){ 'i', "int", "test int", i }; 46 options[1] = (cfa_option){ 'u', "unsigned", "test unsigned", u }; 47 options[2] = (cfa_option){ 'l', "unsignedlong", "test unsigned long", ul }; 48 options[3] = (cfa_option){ 'L', "unsignedlonglong", "test unsigned long long", ull }; 49 options[4] = (cfa_option){ 'd', "double", "test double", d }; 52 50 53 51 char **left; 54 parse_args( options, options_cnt,"[OPTIONS]...\ntesting bool parameters", left);52 parse_args( options, "[OPTIONS]...\ntesting bool parameters", left); 55 53 56 54 sout | "int :" | i; -
tests/configs/usage.cfa
r72b5805e rd1abc63c 15 15 // 16 16 17 #include <fstream.hfa> 17 18 #include <parseargs.hfa> 18 #include <fstream.hfa>19 19 20 20 #include "../meta/fork+exec.hfa" … … 25 25 sout | "No args, no errors"; 26 26 if(pid_t child = strict_fork(); child == 0) { 27 cfa_option opts[0];28 print_args_usage(1, fake_argv, opts, 0,"Test usage", false);27 array( cfa_option, 0 ) opts; 28 print_args_usage(1, fake_argv, opts, "Test usage", false); 29 29 } 30 30 else { … … 35 35 sout | "No args, with errors"; 36 36 if(pid_t child = strict_fork(); child == 0) { 37 cfa_option opts[0];38 print_args_usage(1, fake_argv, opts, 0,"Test usage", true);37 array( cfa_option, 0 ) opts; 38 print_args_usage(1, fake_argv, opts, "Test usage", true); 39 39 } 40 40 else { … … 46 46 if(pid_t child = strict_fork(); child == 0) { 47 47 int a, b, c; 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); 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); 54 53 } 55 54 else { … … 61 60 if(pid_t child = strict_fork(); child == 0) { 62 61 int a, b, c; 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); 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); 69 67 } 70 68 else { … … 76 74 if(pid_t child = strict_fork(); child == 0) { 77 75 int a, b, c; 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); 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); 84 81 } 85 82 else { … … 91 88 if(pid_t child = strict_fork(); child == 0) { 92 89 int a, b, c; 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); 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); 99 95 } 100 96 else { … … 106 102 if(pid_t child = strict_fork(); child == 0) { 107 103 int a, b, c; 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); 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); 114 109 } 115 110 else {
Note: See TracChangeset
for help on using the changeset viewer.