Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/io.c

    r53a6c2a r5a7966bb  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 23:26:12 2017
    13 // Update Count     : 78
     12// Last Modified On : Thu Jun  8 09:52:10 2017
     13// Update Count     : 51
    1414//
    1515
     
    4242        sout | endl;
    4343
    44         sout | "opening delimiters" | endl;
    4544        sout
     45                // opening delimiters
    4646                | "x (" | 1
    4747                | "x [" | 2
     
    5454                | "x ¿" | 9
    5555                | "x «" | 10
    56                 | endl | endl;
    57 
    58         sout | "closing delimiters" | endl;
     56                | endl;
    5957        sout
     58                // closing delimiters
    6059                | 1 | ", x"
    6160                | 2 | ". x"
     
    6968                | 10 | "] x"
    7069                | 11 | "} x"
    71                 | endl | endl;
    72 
    73         sout | "opening/closing delimiters" | endl;
     70                | endl;
    7471        sout
     72                // opening-closing delimiters
    7573                | "x`" | 1 | "`x'" | 2
    7674                | "'x\"" | 3 | "\"x:" | 4
     
    7876                | "\tx\f" | 7 | "\fx\v" | 8
    7977                | "\vx\n" | 9 | "\nx\r" | 10
    80                 | "\rx"
    81                 | endl | endl;
    82 
    83         sout | "override opening/closing delimiters" | endl;
     78                | "\rx" |
     79                endl;
    8480        sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl;
    85         sout | endl;
    8681
    8782        ifstream in;                                                                            // create / open file
    8883        open( &in, "io.data", "r" );
    8984
    90         sout | "input bacis types" | endl;
    9185        &in | &c                                                                                        // character
    9286                | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli     // integral
     
    9488                | &fc | &dc | &ldc                                                              // floating-point complex
    9589                | cstr( s1 ) | cstr( s2, size );                                // C string, length unchecked and checked
    96         sout | endl;
    9790
    98         sout | "output basic types" | endl;
    9991        sout | c | ' ' | endl                                                           // character
    10092                | si | usi | i | ui | li | uli | lli | ulli | endl // integral
     
    10294                | fc | dc | ldc | endl;                                                 // complex
    10395        sout | endl;
    104 
    105         sout | "tuples" | endl;
    106         [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
    107         sout | t1 | t2 | endl;                                                          // print tuple
     96        sout | f | "" | d | "" | ld | endl                                      // floating point without separator
     97                | sepDisable | fc | dc | ldc | sepEnable | endl // complex without separator
     98                | sepOn | s1 | sepOff | s2 | endl                               // local separator removal
     99                | s1 | "" | s2 | endl;                                                  // C string without separator
    108100        sout | endl;
    109101
    110         sout | "toggle separator" | endl;
    111         sout | f | "" | d | "" | ld | endl                                      // floating point without separator
    112                 | sepDisable | fc | dc | ldc | endl                             // complex without separator
    113                 | fc | sepOn | dc | ldc | endl                                  // local separator add
    114                 | sepEnable | fc | dc | ldc | endl                              // complex with separator
    115                 | fc | sepOff | dc | ldc | endl                                 // local separator removal
    116                 | s1 | sepOff | s2 | endl                                               // local separator removal
    117                 | s1 | "" | s2 | endl;                                                  // local separator removal
     102        sepSet( sout, ", $" );                                                          // change separator, maximum of 15 characters
     103        sout | f | d | ld | endl
     104                | fc | dc | ldc | endl
     105                | s1 | s2 | endl;
    118106        sout | endl;
    119107
    120         sout | "change separator" | endl;
    121         sout | "from \"" | sep | "\"";
    122         sepSet( sout, ", $" );                                                          // change separator, maximum of 15 characters
    123         sout | " to \"" | sep | "\"" | endl;
    124         sout | f | d | ld | endl
    125                 | fc | dc | ldc | endl
    126                 | s1 | s2 | endl
    127                 | t1 | t2 | endl;                                                               // print tuple
    128         sout | endl;
    129         sout | "from \"" | sep | "\" ";
    130         sepSet( sout, " " );                                                            // restore separator
    131         sout | "to \"" | sep | "\"" | endl;
    132         sout | f | d | ld | endl
    133                 | fc | dc | ldc | endl
    134                 | s1 | s2 | endl
    135                 | t1 | t2 | endl;                                                               // print tuple
    136         sout | endl;
     108        [int, int] t1 = [1, 2], t2 = [3, 4];
     109        sout | t1 | t2 | endl;                                                          // print tuple
    137110
    138         sout | "check sepOn/sepOff" | endl;
    139         sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // no separator at start/end of line
     111        sepSet( sout, " " );
     112        sepSet( sout, ", $" );                                                          // set separator from " " to ", $"
     113        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
     114        sepSet( sout, " " );                                                            // reset separator to " "
     115        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
     116
     117        sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // separator at start of line
    140118        sout | 1 | sepOff | 2 | 3 | endl;                                       // locally turn off implicit separator
    141         sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line
    142         sout | 1 | 2 | 3 | "\n\n" | sepOn;                                      // no separator at start of next line
    143         sout | 1 | 2 | 3 | endl;
    144         sout | endl;
    145119
    146         sout | "check enable/disable" | endl;
    147120        sout | sepDisable | 1 | 2 | 3 | endl;                           // globally turn off implicit separation
    148121        sout | 1 | sepOn | 2 | 3 | endl;                                        // locally turn on implicit separator
    149         sout | sepEnable | 1 | 2 | 3 | endl | sepDisable;       // globally turn on/off implicit separation
    150         sout | 1 | 2 | 3 | endl | sepEnable;                            // globally turn on implicit separation
    151         sout | 1 | 2 | 3 | sepOn | sepDisable | endl;           // ignore seperate at end of line
    152         sout | 1 | 2 | 3 | sepOn | sepEnable | endl;            // separator at end of line
    153         sout | 1 | 2 | 3 | endl;
    154         sout | endl;
    155 
    156 //      sout | fmt( d, "%8.3f" ) || endl;
    157 //      sout | endl;
     122        sout | sepEnable | 1 | 2 | 3 | endl;                            // globally turn on implicit separation
    158123
    159124        sepSetTuple( sout, " " );                                                       // set tuple separator from ", " to " "
    160         sout | t1 | t2 | " \"" | sep | "\"" | endl;
     125        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    161126        sepSetTuple( sout, ", " );                                                      // reset tuple separator to ", "
    162         sout | t1 | t2 | " \"" | sep | "\"" | endl;
     127        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     128
    163129        sout | t1 | t2 | endl;                                                          // print tuple
    164         sout | endl;
    165130
    166131        [int, int, const char *, double] t3 = { 3, 4, "a", 7.2 };
Note: See TracChangeset for help on using the changeset viewer.