1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2008 - DIGITEO - Allan CORNET
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 // <-- CLI SHELL MODE -->
9 nstr = strcat(string(1:n),' ');
10 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
11 ierr = execstr("sscanf(1,''%d'')", "errcatch");
12 if ierr <> 999 then bugmes();quit;end
13 [A1, A2, A3, A4, A5, A6, A7, A8] = sscanf(nstr, fstr);
15 if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then bugmes();quit;end
17 args = strcat( v(ones(n,1)) + string(1:n)',',');
18 ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
20 ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
21 if ierr <> 0 then bugmes();quit;end
22 if r <> %f then bugmes();quit;end
24 nstr = strcat(string(1:n),' ');
25 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
27 args = strcat( v(ones(n,1)) + string(1:n)',',');
28 ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
29 if ierr <> 999 then bugmes();quit;end
31 nstr = strcat(string(1:n),' ');
32 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
33 mputl(nstr,TMPDIR+'/fscanf.txt');
34 [A1, A2, A3, A4, A5, A6, A7, A8] = fscanf(TMPDIR+'/fscanf.txt',fstr);
36 if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then bugmes();quit;end
38 args = strcat( v(ones(n,1)) + string(1:n)',',');
39 ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
41 ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
42 if ierr <> 0 then bugmes();quit;end
43 if r <> %f then bugmes();quit;end
45 nstr = strcat(string(1:n),' ');
46 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
48 args = strcat( v(ones(n,1)) + string(1:n)',',');
49 ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
50 if ierr <> 999 then bugmes();quit;end
52 if sscanf('123','%i')<>123 then bugmes();quit;end
53 if sscanf(' 123','%i')<>123 then bugmes();quit;end
54 if sscanf('123','%2i')<>12 then bugmes();quit;end
55 if sscanf('123','%0i')<>123 then bugmes();quit;end
56 if sscanf('123','%5i')<>123 then bugmes();quit;end
58 if sscanf('+123','%u')<>123 then bugmes();quit;end
59 if sscanf(' 123','%2u')<>12 then bugmes();quit;end
60 if sscanf('123','%0u')<>123 then bugmes();quit;end
61 if sscanf('+123','%5u')<>123 then bugmes();quit;end
62 //test format %e %f %g
63 if sscanf('123','%e')<>123 then bugmes();quit;end
64 if sscanf(' 123','%e')<>123 then bugmes();quit;end
65 if sscanf('123','%2e')<>12 then bugmes();quit;end
66 if sscanf('123','%0e')<>123 then bugmes();quit;end
67 if sscanf('123','%5e')<>123 then bugmes();quit;end
69 if sscanf('123','%s')<>'123' then bugmes();quit;end
70 if sscanf(' 123','%s')<>'123' then bugmes();quit;end
71 if sscanf('123','%2s')<>'12' then bugmes();quit;end
72 if sscanf('123','%0s')<>'123' then bugmes();quit;end
73 if sscanf('123','%5s')<>'123' then bugmes();quit;end
75 if sscanf('123','%o')<>83 then bugmes();quit;end
76 if sscanf(' 123','%o')<>83 then bugmes();quit;end
77 if sscanf('123','%2o')<>10 then bugmes();quit;end
78 if sscanf('123','%0o')<>83 then bugmes();quit;end
79 if sscanf('123','%5o')<>83 then bugmes();quit;end
81 if sscanf('123','%x')<>291 then bugmes();quit;end
82 if sscanf(' 123','%x')<>291 then bugmes();quit;end
83 if sscanf('123','%2x')<>18 then bugmes();quit;end
84 if sscanf('123','%0x')<>291 then bugmes();quit;end
85 if sscanf('123','%5x')<>291 then bugmes();quit;end
87 if sscanf('123','%c')<>'1' then bugmes();quit;end
88 if sscanf(' 123','%c')<>' ' then bugmes();quit;end
89 if sscanf('123','%0c')<>'1' then bugmes();quit;end
90 //test des format complexes
91 if sscanf('123 4','%*s%s')<>'4' then bugmes();quit;end
92 if sscanf('123 4','123%e')<>4 then bugmes();quit;end
93 [a,b,c]=sscanf('xxxxx 4 test 23.45','xxxxx%i%s%e')
103 if a<>4|b<>'test'|c<>23.45 then bugmes();quit;end
104 [a,b]=sscanf('123\n456','%e%e')
111 if a<>123|b<>456 then bugmes();quit;end