mfprintf: implicit loop over column vectors now prints a new line after each iteratio...
[scilab.git] / scilab / modules / fileio / tests / unit_tests / mfprintf.dia.ref
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2015 - Scilab Enterprises - John GLIKSBERG
4 // Copyright (C) ????-2008 - INRIA
5 // Copyright (C) ????-2008 - ENPC
6 //
7 //  This file is distributed under the same license as the Scilab package.
8 // =============================================================================
9 // <-- CLI SHELL MODE -->
10 function [rep]=Fprintf(varargin)
11     fd = mopen(TMPDIR+"/fprintf.rep","w");
12     varargin(0)=fd;
13     mfprintf(varargin(:));
14     mclose(fd);
15     fd  = mopen(TMPDIR+"/fprintf.rep","r");
16     str = mgetl(fd);
17     mclose(fd);
18     rep = str;
19 endfunction
20 function [y]=bugnum(str1,str2,str3)
21     [lhs,rhs] = argn(0);
22     if rhs==3 then
23         y = or(str1<>str2) & or(str1<>str3);
24     else
25         y = or(str1<>str2);
26     end
27 endfunction
28 // test format "%f"
29 // =============================================================================
30 if bugnum(Fprintf("%f",-35),"-35.000000" ) then bugmes();quit;end
31 if bugnum(Fprintf("%f",35.55),"35.550000" ) then bugmes();quit;end
32 if bugnum(Fprintf("%f",0.00433),"0.004330" , " .004330" ) then bugmes();quit;end
33 if bugnum(Fprintf("%f",0.0000000345456),"0.000000" , " .000000" ) then bugmes();quit;end
34 if bugnum(Fprintf("%f",1112423453),"1112423453.000000" ) then bugmes();quit;end
35 if bugnum(Fprintf("%15f",-35),"     -35.000000" ) then bugmes();quit;end
36 if bugnum(Fprintf("%15f",0.00433),"       0.004330","        .004330" ) then bugmes();quit;end
37 if bugnum(Fprintf("%15f",0.0000000345456),"       0.000000" ,"        .000000" ) then bugmes();quit;end
38 if bugnum(Fprintf("%15f",1112423453),"1112423453.000000" ) then bugmes();quit;end
39 if bugnum(Fprintf("%.1f",-35),"-35.0" ) then bugmes();quit;end
40 if bugnum(Fprintf("%.0f",-35),"-35" ) then bugmes();quit;end
41 if bugnum(Fprintf("%#.0f",-35),"-35." ) then bugmes();quit;end
42 if bugnum(Fprintf("%.1f",0.00433),"0.0"," .0") then bugmes();quit;end
43 if bugnum(Fprintf("%.15f",0.0000000345456),"0.000000034545600" ," .000000034545600" ) then bugmes();quit;end
44 if bugnum(Fprintf("%.1f",11124234534545),"11124234534545.0" ) then bugmes();quit;end
45 // test format "%g"
46 // =============================================================================
47 if bugnum(Fprintf("%g",-35),"-35" ) then bugmes();quit;end
48 if bugnum(Fprintf("%g",35.55),"35.55" ) then bugmes();quit;end
49 if bugnum(Fprintf("%g",35.551234567890),"35.5512" ) then bugmes();quit;end
50 if bugnum(Fprintf("%+g",35.551234567890),"+35.5512" ) then bugmes();quit;end
51 if bugnum(Fprintf("%g",0.00433),"0.00433" ," .00433" ) then bugmes();quit;end
52 if bugnum(Fprintf("%g",0.0000000345456),"3.45456e-08","3.45456e-008" ) then bugmes();quit;end
53 if bugnum(Fprintf("%g",11124234534545),"1.11242e+13","1.11242e+013" ) then bugmes();quit;end
54 if bugnum(Fprintf("%15g",-35),"            -35" ) then bugmes();quit;end
55 if bugnum(Fprintf("%15g",0.00433),"        0.00433","         .00433" ) then bugmes();quit;end
56 if bugnum(Fprintf("%15g",0.0000000345456),"    3.45456e-08","   3.45456e-008" ) then bugmes();quit;end
57 if bugnum(Fprintf("%15g",11124234534545),"    1.11242e+13","   1.11242e+013" ) then bugmes();quit;end
58 if bugnum(Fprintf("%.1g",-35.1),"-4e+01","-4e+001" ) then bugmes();quit;end
59 if bugnum(Fprintf("%.0g",-35.1),"-4e+01","-4e+001"  ) then bugmes();quit;end
60 if bugnum(Fprintf("%#.0g",-35.1),"-4.e+01","-4.e+001" ) then bugmes();quit;end
61 if bugnum(Fprintf("%#.0G",-35.1),"-4.E+01","-4.E+001" ) then bugmes();quit;end
62 if bugnum(Fprintf("%.1g",0.00433),"0.004" ," .004" ) then bugmes();quit;end
63 if bugnum(Fprintf("%.15g",0.0000000345456),"3.45456e-08","3.45456e-008" ) then bugmes();quit;end
64 if bugnum(Fprintf("%.1g",11124234534545),"1e+13","1e+013" ) then bugmes();quit;end
65 // test format "%e"
66 // =============================================================================
67 if bugnum(Fprintf("%e",-35),"-3.500000e+01","-3.500000e+001" ) then bugmes();quit;end
68 if bugnum(Fprintf("%e",35.55),"3.555000e+01","3.555000e+001" ) then bugmes();quit;end
69 if bugnum(Fprintf("%+e",35.55),"+3.555000e+01","+3.555000e+001" ) then bugmes();quit;end
70 if bugnum(Fprintf("%e",35.551234567890),"3.555123e+01","3.555123e+001" ) then bugmes();quit;end
71 if bugnum(Fprintf("%e",0.00433),"4.330000e-03","4.330000e-003" ) then bugmes();quit;end
72 if bugnum(Fprintf("%e",0.0000000345456),"3.454560e-08","3.454560e-008" ) then bugmes();quit;end
73 if bugnum(Fprintf("%e",11124234534545),"1.112423e+13","1.112423e+013" ) then bugmes();quit;end
74 if bugnum(Fprintf("%E",11124234534545),"1.112423E+13","1.112423E+013" ) then bugmes();quit;end
75 if bugnum(Fprintf("%15e",-35),"  -3.500000e+01"," -3.500000e+001" ) then bugmes();quit;end
76 if bugnum(Fprintf("%15e",0.00433),"   4.330000e-03","  4.330000e-003" ) then bugmes();quit;end
77 if bugnum(Fprintf("%15e",0.0000000345456),"   3.454560e-08","  3.454560e-008" ) then bugmes();quit;end
78 if bugnum(Fprintf("%+15e",0.0000000345456),"  +3.454560e-08"," +3.454560e-008" ) then bugmes();quit;end
79 if bugnum(Fprintf("%15e",11124234534545),"   1.112423e+13","  1.112423e+013" ) then bugmes();quit;end
80 if bugnum(Fprintf("%.1e",-35),"-3.5e+01","-3.5e+001" ) then bugmes();quit;end
81 if bugnum(Fprintf("%.0e",-35.1),"-4e+01" ,"-4e+001" ) then bugmes();quit;end
82 if bugnum(Fprintf("%#.0e",-35.1),"-4.e+01","-4.e+001" ) then bugmes();quit;end
83 if bugnum(Fprintf("%.1e",0.00433),"4.3e-03","4.3e-003" ) then bugmes();quit;end
84 if bugnum(Fprintf("%.15e",0.0000000345456),"3.454560000000000e-08","3.454560000000000e-008" ) then bugmes();quit;end
85 if bugnum(Fprintf("%.1e",11124234534545),"1.1e+13","1.1e+013" ) then bugmes();quit;end
86 // test format "%c"
87 // =============================================================================
88 if bugnum(Fprintf("%c","t"),"t" ) then bugmes();quit;end
89 if bugnum(Fprintf("%10c","t"),"         t" ) then bugmes();quit;end
90 if bugnum(Fprintf("%10.3c","t"),"         t" ) then bugmes();quit;end
91 if bugnum(Fprintf("%-10c","t"),"t         " ) then bugmes();quit;end
92 // test format "%s"
93 // =============================================================================
94 if bugnum(Fprintf("%s","text"),"text" ) then bugmes();quit;end
95 if bugnum(Fprintf("%10s","text"),"      text" ) then bugmes();quit;end
96 if bugnum(Fprintf("%10.3s","text"),"       tex" ) then bugmes();quit;end
97 if bugnum(Fprintf("%-10s","text"),"text      " ) then bugmes();quit;end
98 if bugnum(Fprintf("%s","t"),"t" ) then bugmes();quit;end
99 // test format "%x"
100 // =============================================================================
101 if bugnum(Fprintf("%x",123),"7b" ) then bugmes();quit;end
102 if bugnum(Fprintf("%.10x",123),"000000007b" ) then bugmes();quit;end
103 if bugnum(Fprintf("%x",-123),"ffffff85" ) then bugmes();quit;end
104 if bugnum(Fprintf("%X",-123),"FFFFFF85" ) then bugmes();quit;end
105 if bugnum(Fprintf("%#.3X",12),"0X00C" ) then bugmes();quit;end
106 //----------test format %o
107 //if bugnum(Fprintf('%015o',-12),'000037777777764' ) then bugmes();quit;end
108 //----------test column vector input
109 if bugnum(Fprintf("%s\n", ["a";"b"]), ["a";"b"]) then bugmes();quit;end