Changeset 168 for trunk/Test.pas


Ignore:
Timestamp:
Jul 1, 2023, 8:17:50 PM (17 months ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Test.pas

    r152 r168  
    44
    55uses
    6   Classes, SysUtils, VCard, VCardProcessor, TestCase;
     6  Classes, SysUtils, VCard, VCardProcessor, TestCase, Table;
    77
    88type
     
    4040  end;
    4141
     42  { TTestCaseVCardExportImport }
     43
     44  TTestCaseVCardExportImport = class(TTestCase)
     45    Input: string;
     46    Output: string;
     47    Format: TTableFormat;
     48    HumanReadableHeader: Boolean;
     49    procedure Run; override;
     50  end;
     51
    4252
    4353implementation
     
    4959  SExpected = 'Expected:';
    5060  SOutput = 'Output:';
     61  SExport = 'Export:';
     62
     63{ TTestCaseVCardExportImport }
     64
     65procedure TTestCaseVCardExportImport.Run;
     66var
     67  Lines: TStringList;
     68  ExportedLines: TStringList;
     69begin
     70  Lines := TStringList.Create;
     71  ExportedLines := TStringList.Create;
     72  try
     73    with TVCardFile.Create(nil) do
     74    try
     75      Lines.Text := Input;
     76      VCard.LoadFromStrings(Lines);
     77
     78      VCard.ExportToStrings(ExportedLines, Format, HumanReadableHeader);
     79      VCard.Contacts.Clear;
     80      VCard.ImportFromStrings(ExportedLines, Format, HumanReadableHeader);
     81
     82      Lines.Text := '';
     83      VCard.SaveToStrings(Lines);
     84      Evaluate(Lines.Text = Output);
     85      Log := SExpected + LineEnding +
     86        '"' + Output + '"' + LineEnding + LineEnding +
     87        SExport + LineEnding +
     88        '"' + ExportedLines.Text + '"' + LineEnding + LineEnding +
     89        SOutput + LineEnding +
     90        '"' + Lines.Text + '"';
     91    finally
     92      Free;
     93    end;
     94  finally
     95    FreeAndNil(Lines);
     96    FreeAndNil(ExportedLines);
     97  end;
     98end;
    5199
    52100{ TTestCaseVCardProcessor }
Note: See TracChangeset for help on using the changeset viewer.