2014-04-03 15:33:18 +02:00
|
|
|
unit StringsTest;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
TestFramework;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TStringsTest = class(TTestCase)
|
|
|
|
published
|
|
|
|
procedure TestSplit;
|
2014-04-03 16:03:28 +02:00
|
|
|
procedure TestSkipEmptyItems;
|
2014-04-03 15:33:18 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
System.Types,
|
|
|
|
|
|
|
|
X2UtStrings;
|
|
|
|
|
|
|
|
|
|
|
|
{ TStringsTest }
|
|
|
|
procedure TStringsTest.TestSplit;
|
|
|
|
var
|
|
|
|
items: TStringDynArray;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Split('value1/value2', '/', items);
|
|
|
|
CheckEquals(2, Length(items), 'Length');
|
|
|
|
CheckEquals('value1', items[0], 'Items[0]');
|
|
|
|
CheckEquals('value2', items[1], 'Items[1]');
|
|
|
|
end;
|
|
|
|
|
2014-04-03 16:03:28 +02:00
|
|
|
|
|
|
|
procedure TStringsTest.TestSkipEmptyItems;
|
|
|
|
var
|
|
|
|
items: TStringDynArray;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Split('/value1///value2//', '/', items, True);
|
|
|
|
CheckEquals(2, Length(items), 'Length');
|
|
|
|
CheckEquals('value1', items[0], 'Items[0]');
|
|
|
|
CheckEquals('value2', items[1], 'Items[1]');
|
|
|
|
end;
|
|
|
|
|
2014-04-03 15:33:18 +02:00
|
|
|
initialization
|
|
|
|
RegisterTest('Strings', TStringsTest.Suite);
|
|
|
|
|
|
|
|
end.
|