Ignore:
Timestamp:
Aug 1, 2006, 8:51:54 PM (19 years ago)
Author:
RBRi
Message:

refactoring for cmd line parameters handling finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/NewViewTests.pas

    r23 r25  
    9696     writeln('CmdLineParameterUnit Tests ''' + nativeOS2GetCmdLineParameter + '''');
    9797
    98      tmpResult := splitCmdLineParameter('', tmpRC);
     98     tmpResult := TStringList.Create;
     99     tmpRC := splitCmdLineParameter('', tmpResult);
    99100     assertEqualsInt('CmdLine split empy string', 0, tmpRC);
    100101     assertEqualsInt('CmdLine split empy string', 0, tmpResult.Count);
    101 
    102      tmpResult := splitCmdLineParameter('abc', tmpRC);
     102     tmpResult.Destroy;
     103
     104     tmpResult := TStringList.Create;
     105     tmpRC := splitCmdLineParameter('abc', tmpResult);
    103106     assertEqualsInt('CmdLine split single string', 0, tmpRC);
    104107     assertEqualsInt('CmdLine split single string', 1, tmpResult.Count);
    105108     assertEqualsString('CmdLine split single string', 'abc', tmpResult[0]);
    106 
    107      tmpResult := splitCmdLineParameter(' abc', tmpRC);
     109     tmpResult.Destroy;
     110
     111     tmpResult := TStringList.Create;
     112     tmpRC := splitCmdLineParameter(' abc', tmpResult);
    108113     assertEqualsInt('CmdLine split single string with leading blank', 0, tmpRC);
    109114     assertEqualsInt('CmdLine split single string with leading blank', 1, tmpResult.Count);
    110115     assertEqualsString('CmdLine split single string with leading blankCmdLine split many strings', 'abc', tmpResult[0]);
    111 
    112      tmpResult := splitCmdLineParameter('abc def ghi', tmpRC);
     116     tmpResult.Destroy;
     117
     118     tmpResult := TStringList.Create;
     119     tmpRC := splitCmdLineParameter('abc def ghi', tmpResult);
    113120     assertEqualsInt('CmdLine split empy string', 0, tmpRC);
    114121     assertEqualsInt('CmdLine split many strings', 3, tmpResult.Count);
     
    116123     assertEqualsString('CmdLine split many strings', 'def', tmpResult[1]);
    117124     assertEqualsString('CmdLine split many strings', 'ghi', tmpResult[2]);
    118 
    119      tmpResult := splitCmdLineParameter('"abc def"', tmpRC);
     125     tmpResult.Destroy;
     126
     127     tmpResult := TStringList.Create;
     128     tmpRC := splitCmdLineParameter('"abc def"', tmpResult);
    120129     assertEqualsInt('CmdLine split quoted (1)', 0, tmpRC);
    121130     assertEqualsInt('CmdLine split quoted (1)', 1, tmpResult.Count);
    122131     assertEqualsString('CmdLine split quoted (1)', 'abc def', tmpResult[0]);
    123 
    124      tmpResult := splitCmdLineParameter('ab"abc def"', tmpRC);
     132     tmpResult.Destroy;
     133
     134     tmpResult := TStringList.Create;
     135     tmpRC := splitCmdLineParameter('ab"abc def"', tmpResult);
    125136     assertEqualsInt('CmdLine split quoted (2)', 0, tmpRC);
    126137     assertEqualsInt('CmdLine split quoted (2)', 1, tmpResult.Count);
    127138     assertEqualsString('CmdLine split quoted (2)', 'ababc def', tmpResult[0]);
    128 
    129      tmpResult := splitCmdLineParameter('ab"""abc def"', tmpRC);
     139     tmpResult.Destroy;
     140
     141     tmpResult := TStringList.Create;
     142     tmpRC := splitCmdLineParameter('ab"""abc def"', tmpResult);
    130143     assertEqualsInt('CmdLine split quoted (3)', 0, tmpRC);
    131144     assertEqualsInt('CmdLine split quoted (3)', 1, tmpResult.Count);
    132145     assertEqualsString('CmdLine split quoted (3)', 'ab"abc def', tmpResult[0]);
    133 
    134      tmpResult := splitCmdLineParameter('ab"abc""def"', tmpRC);
     146     tmpResult.Destroy;
     147
     148     tmpResult := TStringList.Create;
     149     tmpRC := splitCmdLineParameter('ab"abc""def"', tmpResult);
    135150     assertEqualsInt('CmdLine split quoted (4)', 0, tmpRC);
    136151     assertEqualsInt('CmdLine split quoted (4)', 1, tmpResult.Count);
    137152     assertEqualsString('CmdLine split quoted (4)', 'ababc"def', tmpResult[0]);
    138 
    139      tmpResult := splitCmdLineParameter('ab"abc""def" "ghi"', tmpRC);
     153     tmpResult.Destroy;
     154
     155     tmpResult := TStringList.Create;
     156     tmpRC := splitCmdLineParameter('ab"abc""def" "ghi"', tmpResult);
    140157     assertEqualsInt('CmdLine split quoted (5)', 0, tmpRC);
    141158     assertEqualsInt('CmdLine split quoted (5)', 2, tmpResult.Count);
    142159     assertEqualsString('CmdLine split quoted (5)', 'ababc"def', tmpResult[0]);
    143160     assertEqualsString('CmdLine split quoted (5)', 'ghi', tmpResult[1]);
    144 
    145      tmpResult := splitCmdLineParameter('ab"abc""def" "ghi', tmpRC);
     161     tmpResult.Destroy;
     162
     163     tmpResult := TStringList.Create;
     164     tmpRC := splitCmdLineParameter('ab"abc""def" "ghi', tmpResult);
    146165     assertEqualsInt('CmdLine split quoted (6)', -1, tmpRC);
    147166     assertEqualsInt('CmdLine split quoted (6)', 2, tmpResult.Count);
    148167     assertEqualsString('CmdLine split quoted (6)', 'ababc"def', tmpResult[0]);
    149168     assertEqualsString('CmdLine split quoted (6)', 'ghi', tmpResult[1]);
     169     tmpResult.Destroy;
    150170
    151171     // parser Tests
     
    510530     tmpCmdLineParameters := TCmdLineParameters.Create;
    511531     tmpCmdLineParameters.parseCmdLine(tmpParams);
    512      assertEqualsString('parseCmdLine [getFileName](70)', 'ab c', tmpCmdLineParameters.getFileName);
    513      assertEqualsString('parseCmdLine [getTopic](70)', 'topi1 topi2', tmpCmdLineParameters.getTopic);
     532     assertEqualsString('parseCmdLine [getFileName](70)', 'ab c', tmpCmdLineParameters.getFileNames);
     533     assertEqualsString('parseCmdLine [getTopic](70)', 'topi1 topi2', tmpCmdLineParameters.getTopics);
     534
    514535END;
    515536
Note: See TracChangeset for help on using the changeset viewer.