Test suite results for test file test/cg/tprintf.pp

Test run data :

Free Pascal Compiler Test Suite Results

View Test suite results

Please specify search criteria:
File:
Operating system:
Processor:
Version
Date
Submitter
Machine
Comment
Limit
Cond
Category
Only failed tests
Hide skipped tests
List all tests

Test file "test/cg/tprintf.pp" information:

t_id 195
t_version 1.1
t_adddate 2003/10/03
t_result 0
t_knownrunerror 0
t_note Note: This test requires a C library

Detailed test run results:

Record count: 50

Total = 50

OK=50 Percentage= 100.00

Result type Cat. Count Percentage First date Last Date
Successfully run 50 100.0 2024/05/20 09:37:00 26 2024/05/20 22:30:00 59
i386 14 28.0 2024/05/20 09:37:00 26 2024/05/20 17:30:00 45
arm 1 2.0 2024/05/20 22:30:00 59 2024/05/20 22:30:00 59
x86_64 13 26.0 2024/05/20 13:38:00 23 2024/05/20 19:35:00 26
mips 3 6.0 2024/05/20 10:56:00 35 2024/05/20 14:28:00 35
aarch64 19 38.0 2024/05/20 10:24:00 38 2024/05/20 22:24:00 44
linux 11 22.0 2024/05/20 10:24:00 38 2024/05/20 22:30:00 59
win32 1 2.0 2024/05/20 09:37:00 26 2024/05/20 09:37:00 26
go32v2 1 2.0 2024/05/20 10:22:00 73 2024/05/20 10:22:00 73
solaris 12 24.0 2024/05/20 16:23:00 44 2024/05/20 17:30:00 45
darwin 12 24.0 2024/05/20 16:20:00 32 2024/05/20 17:50:00 56
win64 13 26.0 2024/05/20 13:38:00 23 2024/05/20 19:35:00 26
3.3.1 10 20.0 2024/05/20 10:22:00 73 2024/05/20 19:35:00 26
3.2.2 12 24.0 2024/05/20 16:23:00 44 2024/05/20 17:30:00 45
3.2.3 28 56.0 2024/05/20 09:37:00 26 2024/05/20 22:30:00 59

Source:

{ %version=1.1 }
{ %NOTE=This test requires a C library }

{$mode objfpc}

uses
  strings;

{$ifdef win32}
{$linklib msvcrt}
procedure printf(const formatstr : pchar; const args : array of const);cdecl; external name 'printf';
procedure sprintf(p : pchar;const formatstr : pchar; const args : array of const);cdecl; external name 'sprintf';
const
  int64prefix='I64';
{$else}
{$linklib c}
procedure printf(const formatstr : pchar; const args : array of const);cdecl; external;
procedure sprintf(p : pchar;const formatstr : pchar; const args : array of const);cdecl; external;
const
  int64prefix='ll';
{$endif}



type
 THandle = longint;
const
  l : longint = 45;
  ll : int64 = 345;
  s : pchar = 'Enclosed text';
  s2 : pchar = 'next';
  si : single = 32.12;
  d : double = 45.45;
  e : extended = 74.74;
  p : pchar = nil;
  has_errors : boolean = false;

begin
  getmem(p,500);

  Writeln('Testing C printf function called from FPC code');
//  printf('Simple test without arg'#10,[]);
  Writeln('Testing with single pchar argument');
  printf('Text containing "%s" text'#10,[s]);
  sprintf(p,'Text containing "%s" text'#10,[s]);
  if strpos(p,'g "Enclosed text" ')=nil then
    begin
      writeln('The output of sprintf for pchar is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single longint argument');
  printf('Text containing longint: %d'#10,[l]);
  sprintf(p,'Text containing longint: %d'#10,[l]);
  if strpos(p,'longint: 45')=nil then
    begin
      writeln('The output of sprintf for longint is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single int64 argument');
  printf('Text containing int64: %'+int64prefix+'d'#10,[ll]);
  sprintf(p,'Text containing int64: %'+int64prefix+'d'#10,[ll]);
  if strpos(p,'int64: 345')=nil then
    begin
      writeln('The output of sprintf for int64 is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single single argument');
  printf('Text containing single: %f'#10,[si]);
  sprintf(p,'Text containing single: %f'#10,[si]);
  if strpos(p,'single: 32.1')=nil then
    begin
      writeln('The output of sprintf for double is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single double argument');
  printf('Text containing double: %f'#10,[d]);
  sprintf(p,'Text containing double: %f'#10,[d]);
  if strpos(p,'double: 45.4')=nil then
    begin
      writeln('The output of sprintf for double is wrong: ',p);
      has_errors:=true;
    end;

  printf('Text containing long double: %f'#10,[e]);
  sprintf(p,'Text containing long double: %f'#10,[e]);
  if strpos(p,'long double: 74.7')=nil then
    begin
      writeln('The output of sprintf for long double is wrong:',p);
      has_errors:=true;
    end;

  Writeln('Testing with combined pchar argument');
  printf('Text containing "%s" and "%s" text'#10,[s,s2]);
  sprintf(p,'Text containing "%s" and "%s" text'#10,[s,s2]);
  if strpos(p,'g "Enclosed text" and "next"')=nil then
    begin
      writeln('The output of sprintf for two pchars is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single longint argument and pchar');
  printf('Text containing longint: %d"%s"'#10,[l,s2]);
  sprintf(p,'Text containing longint: %d"%s"'#10,[l,s2]);
  if strpos(p,'longint: 45"next"')=nil then
    begin
      writeln('The output of sprintf for longint is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single int64 argument and pchar');
  printf('Text containing int64: %'+int64prefix+'d"%s"'#10,[ll,s2]);
  sprintf(p,'Text containing int64: %'+int64prefix+'d"%s"'#10,[ll,s2]);
  if strpos(p,'int64: 345"next"')=nil then
    begin
      writeln('The output of sprintf for int64 is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single single argument');
  printf('Text containing single: %f"%s"'#10,[si,s2]);
  sprintf(p,'Text containing single: %f"%s"'#10,[si,s2]);
  if (strpos(p,'single: 32.1')=nil) or
     (strpos(p,'"next"')=nil) then
    begin
      writeln('The output of sprintf for double is wrong: ',p);
      has_errors:=true;
    end;

  Writeln('Testing with single double argument');
  printf('Text containing double: %f"%s"'#10,[d,s2]);
  sprintf(p,'Text containing double: %f"%s"'#10,[d,s2]);
  if (strpos(p,'double: 45.4')=nil) or
     (strpos(p,'"next"')=nil) then
    begin
      writeln('The output of sprintf for double is wrong: ',p);
      has_errors:=true;
    end;

  printf('Text containing long double: %f"%s"'#10,[e,s2]);
  sprintf(p,'Text containing long double: %f"%s"'#10,[e,s2]);
  if (strpos(p,'long double: 74.7')=nil) or
     (strpos(p,'"next"')=nil) then
    begin
      writeln('The output of sprintf for long double is wrong:',p);
      has_errors:=true;
    end;

  if has_errors then
    halt(1);
end.

Link to SVN view of test/cg/tprintf.pp source.