Changeset 29


Ignore:
Timestamp:
Aug 19, 2006, 8:27:44 PM (19 years ago)
Author:
RBRi
Message:

more parser fixes and new unit tests

Location:
trunk/NewView
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/CmdLineParameterUnit.pas

    r28 r29  
    325325     STATE_INSIDE_QUOTED = 3;
    326326     STATE_INSIDE_QUOTED_START_QUOTE = 4;
     327//     STATE_INSIDE_QUOTED_QUOTE_PROCESSED = 5;
    327328  VAR
    328329     i : Integer;
     
    377378                 begin
    378379                    tmpState := STATE_INSIDE_QUOTED;
    379                     tmpCurrentCommand := tmpCurrentCommand + tmpCurrentChar;
    380                  end;
     380//                    tmpState := STATE_INSIDE_QUOTED_QUOTE_PROCESSED;
     381                    tmpCurrentCommand := tmpCurrentCommand + tmpCurrentChar;
     382                 end;
     383//               STATE_INSIDE_QUOTED_QUOTE_PROCESSED :
     384//                    tmpState := STATE_INSIDE_QUOTED_START_QUOTE;
    381385               ELSE
    382386                    tmpState := STATE_START_QUOTE;
     
    410414                    tmpCurrentCommand := tmpCurrentCommand + tmpCurrentChar;
    411415                 end;
     416//               STATE_INSIDE_QUOTED_QUOTE_PROCESSED :
     417//                 begin
     418//                    tmpCurrentCommand := tmpCurrentCommand + tmpCurrentChar;
     419//                 end;
    412420               end;
    413421            end;
     
    421429          aResult.add(tmpCurrentCommand);
    422430       end;
     431     STATE_START_QUOTE :
     432       begin
     433          result := ERROR_UNMATCHED_QUOTE;
     434       end;
    423435     STATE_INSIDE_QUOTED_START_QUOTE :
    424436       begin
    425           aResult.add(tmpCurrentCommand);
     437          if (0 < length(tmpCurrentCommand)) then
     438          begin
     439            aResult.add(tmpCurrentCommand);
     440          end;
    426441       end;
     442     STATE_INSIDE_QUOTED :
     443       begin
     444          result := ERROR_UNMATCHED_QUOTE;
     445          if (0 < length(tmpCurrentCommand)) then
     446          begin
     447            aResult.add(tmpCurrentCommand);
     448          end;
     449       end;
     450//     STATE_INSIDE_QUOTED_QUOTE_PROCESSED :
     451//       begin
     452//          result := ERROR_UNMATCHED_QUOTE;
     453//          if (1 < length(tmpCurrentCommand)) then
     454//          begin
     455//            aResult.add(copy(tmpCurrentCommand, 1, length(tmpCurrentCommand)-0));
     456//          end
     457//       end;
    427458     ELSE
    428459       begin
    429460          result := ERROR_UNMATCHED_QUOTE;
    430           aResult.add(tmpCurrentCommand);
     461          if (0 < length(tmpCurrentCommand)) then
     462          begin
     463            aResult.add(tmpCurrentCommand);
     464          end;
    431465       end;
    432466     end;
  • trunk/NewView/NewView.spr

    r28 r29  
    209209File0.Bottom=-5
    210210File0.Width=1243
    211 File0.Height=443
     211File0.Height=500
    212212File0.Column=18
    213213File0.Line=348
     
    216216File1.Bottom=-5
    217217File1.Width=1243
    218 File1.Height=443
     218File1.Height=500
    219219File1.Column=1
    220220File1.Line=33
     
    223223File2.Bottom=-5
    224224File2.Width=1243
    225 File2.Height=443
     225File2.Height=500
    226226File2.Column=46
    227227File2.Line=4190
  • trunk/NewView/unittests/cmdlineparameterunittests.pas

    r27 r29  
    2020PROCEDURE testSplitCmdLineParameter_TwoQuotedParts;
    2121PROCEDURE testSplitCmdLineParameter_TwoQuotesAtStartEnd;
     22PROCEDURE testSplitCmdLineParameter_Failure_TwoQuotesAtEnd;
    2223PROCEDURE testSplitCmdLineParameter_TwoQuotedPartsMissingClosedQuote;
     24PROCEDURE testSplitCmdLineParameter_1Quote;
     25PROCEDURE testSplitCmdLineParameter_2Quote;
     26PROCEDURE testSplitCmdLineParameter_3Quote;
     27PROCEDURE testSplitCmdLineParameter_4Quote;
     28PROCEDURE testSplitCmdLineParameter_5Quote;
     29PROCEDURE testSplitCmdLineParameter_6Quote;
    2330
    2431PROCEDURE testParseCmdLine_Empty;
     
    235242
    236243
     244  PROCEDURE testSplitCmdLineParameter_Failure_TwoQuotesAtEnd;
     245  VAR
     246    tmpResult : TStringList;
     247    tmpRC : Integer;
     248  BEGIN
     249    tmpResult := TStringList.Create;
     250    tmpRC := splitCmdLineParameter('"abc def""', tmpResult);
     251
     252    assertEqualsInt('testSplitCmdLineParameter_Failure_TwoQuotesAtEnd', -1, tmpRC);
     253    assertEqualsInt('testSplitCmdLineParameter_Failure_TwoQuotesAtEnd', 1, tmpResult.Count);
     254    assertEqualsString('testSplitCmdLineParameter_Failure_TwoQuotesAtEnd', 'abc def"', tmpResult[0]);
     255
     256    tmpResult.Destroy;
     257  END;
     258
     259
    237260  PROCEDURE testSplitCmdLineParameter_TwoQuotedPartsMissingClosedQuote;
    238261  VAR
     
    247270    assertEqualsString('testSplitCmdLineParameter_TwoQuotedPartsMissingClosedQuote', 'ababc"def', tmpResult[0]);
    248271    assertEqualsString('testSplitCmdLineParameter_TwoQuotedPartsMissingClosedQuote', 'ghi', tmpResult[1]);
     272
     273    tmpResult.Destroy;
     274  END;
     275
     276
     277  PROCEDURE testSplitCmdLineParameter_1Quote;
     278  VAR
     279    tmpResult : TStringList;
     280    tmpRC : Integer;
     281  BEGIN
     282    tmpResult := TStringList.Create;
     283    tmpRC := splitCmdLineParameter('"', tmpResult);
     284
     285    assertEqualsInt('testSplitCmdLineParameter_1Quote', -1, tmpRC);
     286    assertEqualsInt('testSplitCmdLineParameter_1Quote', 0, tmpResult.Count);
     287
     288    tmpResult.Destroy;
     289  END;
     290
     291
     292  PROCEDURE testSplitCmdLineParameter_2Quote;
     293  VAR
     294    tmpResult : TStringList;
     295    tmpRC : Integer;
     296  BEGIN
     297    tmpResult := TStringList.Create;
     298    tmpRC := splitCmdLineParameter('""', tmpResult);
     299
     300    assertEqualsInt('testSplitCmdLineParameter_2Quote', 0, tmpRC);
     301    assertEqualsInt('testSplitCmdLineParameter_2Quote', 0, tmpResult.Count);
     302
     303    tmpResult.Destroy;
     304  END;
     305
     306
     307  PROCEDURE testSplitCmdLineParameter_3Quote;
     308  VAR
     309    tmpResult : TStringList;
     310    tmpRC : Integer;
     311  BEGIN
     312    tmpResult := TStringList.Create;
     313    tmpRC := splitCmdLineParameter('"""', tmpResult);
     314
     315    assertEqualsInt('testSplitCmdLineParameter_3Quote', -1, tmpRC);
     316    assertEqualsInt('', 1, tmpResult.Count);
     317    assertEqualsString('testSplitCmdLineParameter_3Quote', '"', tmpResult[0]);
     318
     319    tmpResult.Destroy;
     320  END;
     321
     322
     323  PROCEDURE testSplitCmdLineParameter_4Quote;
     324  VAR
     325    tmpResult : TStringList;
     326    tmpRC : Integer;
     327  BEGIN
     328    tmpResult := TStringList.Create;
     329    tmpRC := splitCmdLineParameter('""""', tmpResult);
     330
     331    assertEqualsInt('testSplitCmdLineParameter_4Quote', 0, tmpRC);
     332    assertEqualsInt('testSplitCmdLineParameter_4Quote', 1, tmpResult.Count);
     333    assertEqualsString('testSplitCmdLineParameter_4Quote', '"', tmpResult[0]);
     334
     335    tmpResult.Destroy;
     336  END;
     337
     338
     339  PROCEDURE testSplitCmdLineParameter_5Quote;
     340  VAR
     341    tmpResult : TStringList;
     342    tmpRC : Integer;
     343  BEGIN
     344    tmpResult := TStringList.Create;
     345    tmpRC := splitCmdLineParameter('"""""', tmpResult);
     346
     347    assertEqualsInt('testSplitCmdLineParameter_5Quote', -1, tmpRC);
     348    assertEqualsInt('testSplitCmdLineParameter_5Quote', 1, tmpResult.Count);
     349    assertEqualsString('testSplitCmdLineParameter_5Quote', '""', tmpResult[0]);
     350
     351    tmpResult.Destroy;
     352  END;
     353
     354
     355  PROCEDURE testSplitCmdLineParameter_6Quote;
     356  VAR
     357    tmpResult : TStringList;
     358    tmpRC : Integer;
     359  BEGIN
     360    tmpResult := TStringList.Create;
     361    tmpRC := splitCmdLineParameter('""""""', tmpResult);
     362
     363    assertEqualsInt('testSplitCmdLineParameter_6Quote', 0, tmpRC);
     364    assertEqualsInt('testSplitCmdLineParameter_6Quote', 1, tmpResult.Count);
     365    assertEqualsString('testSplitCmdLineParameter_6Quote', '""', tmpResult[0]);
    249366
    250367    tmpResult.Destroy;
     
    870987  BEGIN
    871988    result := TList.Create;
     989
    872990    result.add(@testSplitCmdLineParameter_Empty);
    873991    result.add(@testSplitCmdLineParameter_simpleOne);
     
    881999    result.add(@testSplitCmdLineParameter_TwoQuotedParts);
    8821000    result.add(@testSplitCmdLineParameter_TwoQuotesAtStartEnd);
     1001    result.add(@testSplitCmdLineParameter_Failure_TwoQuotesAtEnd);
    8831002    result.add(@testSplitCmdLineParameter_TwoQuotedPartsMissingClosedQuote);
     1003    result.add(@testSplitCmdLineParameter_1Quote);
     1004    result.add(@testSplitCmdLineParameter_2Quote);
     1005    result.add(@testSplitCmdLineParameter_3Quote);
     1006    result.add(@testSplitCmdLineParameter_4Quote);
     1007    result.add(@testSplitCmdLineParameter_5Quote);
     1008    result.add(@testSplitCmdLineParameter_6Quote);
    8841009
    8851010    result.add(@testParseCmdLine_Empty);
  • trunk/NewView/unittests/newviewtests.spr

    r27 r29  
    5656[Directories]
    5757
    58 LastDir=P:\NEWVIEW_DEV\BUILD\SIBYL\LIB
     58LastDir=P:\NEWVIEW_DEV\NEWVIEW
    5959OutDir=P:\NEWVIEW_DEV\build
    6060LibDir=P:\NEWVIEW_DEV\build\library;P:\NEWVIEW_DEV\build\sibyl\lib
    61 LibSrcDir=D:\PROGS\SIBYL\Source\RTL;D:\PROGS\SIBYL\Source\SPCC
     61LibSrcDir=P:\NEWVIEW_DEV\NEWVIEW;D:\PROGS\SIBYL\Source\RTL;D:\PROGS\SIBYL\Source\SPCC
    6262IncSrcDir=
    6363CompInstallDir=D:\PROGS\SIBYL\Compnt
     
    6565[Find History]
    6666
    67 Find0=testParseCmdLine_HelpManagerText
    68 Find1=tmpCmdLineParameters
    69 Find2=testParseCmdLine_doubleColonG
    70 Find3=testParseCmdLine_empty
    71 Find4=testParseCmdLine_upperHELP
    72 Find5=testParseCmdLine_h
    73 Find6=testSplitCmdLineParameter_simpleOne
    74 Find7=Assert
    75 Find8=testSplitCmdLineParameter_Empty
    76 Find9=FUNCTION
    77 Find10=Exception
    78 Find11=VAR
    79 Find12=Pointer
    80 Find13=xxx
    81 Find14=split
    82 Find15=assertTrue
     67Find0=missing
     68Find1=2
     69Find2=testParseCmdLine_HelpManagerText
     70Find3=tmpCmdLineParameters
     71Find4=testParseCmdLine_doubleColonG
     72Find5=testParseCmdLine_empty
     73Find6=testParseCmdLine_upperHELP
     74Find7=testParseCmdLine_h
     75Find8=testSplitCmdLineParameter_simpleOne
     76Find9=Assert
     77Find10=testSplitCmdLineParameter_Empty
     78Find11=FUNCTION
     79Find12=Exception
     80Find13=VAR
     81Find14=Pointer
     82Find15=xxx
    8383
    8484[General]
     
    107107File1.Bottom=-5
    108108File1.Width=1243
    109 File1.Height=500
    110 File1.Column=3
    111 File1.Line=869
     109File1.Height=501
     110File1.Column=5
     111File1.Line=1010
    112112File2=.\testassert.pas
    113113File2.Left=-4
     
    116116File2.Height=500
    117117File2.Column=32
    118 File2.Line=61
     118File2.Line=27
     119File3=..\.\CmdLineParameterUnit.pas
     120File3.Left=-4
     121File3.Bottom=-5
     122File3.Width=1243
     123File3.Height=501
     124File3.Column=68
     125File3.Line=422
    119126
    120127[Linker Options]
     
    158165MainFile0.Dependency14=D:\PROGS\SIBYL\Source\RTL\PMGPI.PAS
    159166MainFile0.Dependency15=D:\PROGS\SIBYL\Source\RTL\PMDEV.PAS
    160 MainFile0.Dependency16=.\TESTASSERT.PAS
    161 MainFile0.Dependency17=.\CMDLINEPARAMETERUNITTESTS.PAS
     167MainFile0.Dependency16=..\.\CMDLINEPARAMETERUNIT.PAS
     168MainFile0.Dependency17=.\TESTASSERT.PAS
     169MainFile0.Dependency18=.\CMDLINEPARAMETERUNITTESTS.PAS
    162170
    163171[Replace History]
Note: See TracChangeset for help on using the changeset viewer.