uses
  dstrings,
  dstringpool;

var
  StringPool: TStringPool;
  S: TAnsiView;
  Buffer: array[0 .. 8] of AnsiChar;

begin
  StringPool.Init(4);
  if not StringPool.Append('Hello world', S) then
    Halt(1);
  Writeln(S.ToString);
  if not StringPool.Append('12345', S) then
    Halt(1);
  Writeln(S.ToString);
  if not StringPool.Append('abcdef', S) then
    Halt(1);
  Writeln(S.ToString);
  StringPool.Done;

  StringPool.Init(@Buffer[0], Length(Buffer));
  if not StringPool.Append('123', S) then
    Halt(1);
  Writeln(S.ToString);
  if not StringPool.Append('abc', S) then
    Halt(1);
  Writeln(S.ToString);
  if StringPool.Append('qwerty', S) then
    Halt(1);
  Writeln('Client memory exceed');
  StringPool.Done;

  Writeln('OK');
end.
