Changeset 126 for trunk/UTest.pas


Ignore:
Timestamp:
Apr 6, 2022, 11:36:27 AM (3 years ago)
Author:
chronos
Message:
  • Added: Action to remove exact duplicates.
  • Modified: Test cases definition moved to separate file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTest.pas

    r94 r126  
    3232  end;
    3333
     34  TTestCaseActionKind = (akNone, akRemoveExactDuplicates);
     35
    3436  { TTestCaseLoadSave }
    3537
     
    3739    Input: string;
    3840    Output: string;
     41    Action: TTestCaseActionKind;
    3942    procedure Run; override;
    4043  end;
     
    5053  end;
    5154
     55resourcestring
     56  SNone = 'None';
     57  SPassed = 'Passed';
     58  SFailed = 'Failed';
     59
    5260const
    53   ResultText: array[TTestResult] of string = ('None', 'Passed', 'Failed');
     61  ResultText: array[TTestResult] of string = (SNone, SPassed, SFailed);
     62
     63procedure Translate;
    5464
    5565
    5666implementation
     67
     68resourcestring
     69  SExpected = 'Expected:';
     70  SOutput = 'Output:';
     71
     72procedure Translate;
     73begin
     74 ResultText[trNone] := SNone;
     75 ResultText[trPassed] := SPassed;
     76 ResultText[trFailed] := SFailed;
     77end;
    5778
    5879{ TTestCaseCheckProperty }
     
    7394        Evaluate(PropertyValue = Value);
    7495      end else Fail;
    75       Log := 'Expected:' + LineEnding +
     96      Log := SExpected + LineEnding +
    7697        '"' + Value + '"' + LineEnding + LineEnding +
    77         'Output:' + LineEnding +
     98        SOutput + LineEnding +
    7899        '"' + PropertyValue + '"';
    79100    finally
     
    97118      Lines.Text := Input;
    98119      LoadFromStrings(Lines);
     120
     121      if Action = akRemoveExactDuplicates then
     122        Contacts.RemoveExactDuplicates;
     123
    99124      Lines.Text := '';
    100125      SaveToStrings(Lines);
    101126      Evaluate(Lines.Text = Output);
    102       Log := 'Expected:' + LineEnding +
     127      Log := SExpected + LineEnding +
    103128        '"' + Output + '"' + LineEnding + LineEnding +
    104         'Output:' + LineEnding +
     129        SOutput + LineEnding +
    105130        '"' + Lines.Text + '"';
    106131    finally
Note: See TracChangeset for help on using the changeset viewer.