summaryrefslogtreecommitdiffstats
path: root/scilab/modules/output_stream/tests
diff options
context:
space:
mode:
authorClément David <clement.david@esi-group.com>2021-07-15 15:50:48 +0200
committerClément David <clement.david@esi-group.com>2021-07-15 15:50:48 +0200
commit81a9cc049332de0c712cf56da585fcd25c8e59e3 (patch)
treef365c25a05c1782a16b2985bf7481116c106952d /scilab/modules/output_stream/tests
parentb0937f19e4b8ddf416ca9a9a433bcbbd3f4ef2c0 (diff)
parent90b4ecb9b57ac6ad4e00d4a99b0d8bd1a6424403 (diff)
downloadscilab-master.zip
scilab-master.tar.gz
Merge remote-tracking branch 'origin/6.1'HEADmaster
Change-Id: I5d26fc380a28efe0bb6d0096fe9684b274b55bfe
Diffstat (limited to 'scilab/modules/output_stream/tests')
-rw-r--r--scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref98
-rw-r--r--scilab/modules/output_stream/tests/unit_tests/mprintf.tst31
-rw-r--r--scilab/modules/output_stream/tests/unit_tests/msprintf.tst32
3 files changed, 161 insertions, 0 deletions
diff --git a/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref b/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref
index a45bb94..4f885e4 100644
--- a/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref
+++ b/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref
@@ -1,6 +1,7 @@
1// ============================================================================= 1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA 3// Copyright (C) 2008 - INRIA
4// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================= 7// =============================================================================
@@ -211,3 +212,100 @@ mprintf("==>%10s : %08.4f %08.4f %08.4f<==\n\n",A,C,D);
211==> row 8 : 048.1851 069.7085 089.0622<== 212==> row 8 : 048.1851 069.7085 089.0622<==
212==> row 9 : 026.3956 084.1552 050.4221<== 213==> row 9 : 026.3956 084.1552 050.4221<==
213==> row 10 : 041.4810 040.6202 034.9362<== 214==> row 10 : 041.4810 040.6202 034.9362<==
215// Booleans
216// =============================================================================
217n = [%pi ; %e];
218b = [%T ; %F];
219for f = ["d" "i" "u" "o" "x" "X" "g" "G"]
220 mprintf("%"+f+"\n", b);
221 mprintf("%"+f+" %d\n", b, n);
222 if and(f <> ["u" "o" "x" "X"]) // http://bugzilla.scilab.org/16563
223 mprintf("%2$"+f+" %1$d\n", n, b);
224 end
225end
2261
2270
2281 3
2290 2
2301 3
2310 2
2321
2330
2341 3
2350 2
2361 3
2370 2
2381
2390
2401 3
2410 2
2421
2430
2441 3
2450 2
2461
2470
2481 3
2490 2
2501
2510
2521 3
2530 2
2541
2550
2561 3
2570 2
2581 3
2590 2
2601
2610
2621 3
2630 2
2641 3
2650 2
266// %f
267msprintf("%f\n", b);
268mprintf("%f %d\n", b, n);
2691.000000 3
2700.000000 2
271mprintf("%2$f %1$d\n", n, b);
2721.000000 3
2730.000000 2
274// %e
275mprintf("%e\n", b);
2761.000000e+00
2770.000000e+00
278mprintf("%e %d\n", b, n);
2791.000000e+00 3
2800.000000e+00 2
281mprintf("%2$e %1$d\n", n, b);
2821.000000e+00 3
2830.000000e+00 2
284// %E
285mprintf("%E\n", b);
2861.000000E+00
2870.000000E+00
288mprintf("%E %d\n", b, n);
2891.000000E+00 3
2900.000000E+00 2
291mprintf("%2$E %1$d\n", n, b);
2921.000000E+00 3
2930.000000E+00 2
294// %s, %c
295for f = ["s" "c"]
296 mprintf("%"+f+"\n", b);
297 mprintf("%"+f+" %d\n", b, n);
298 mprintf("%2$"+f+" %1$d\n", n, b);
299end
300T
301F
302T 3
303F 2
304T 3
305F 2
306T
307F
308T 3
309F 2
310T 3
311F 2
diff --git a/scilab/modules/output_stream/tests/unit_tests/mprintf.tst b/scilab/modules/output_stream/tests/unit_tests/mprintf.tst
index 9b5f8ba..d8a0712 100644
--- a/scilab/modules/output_stream/tests/unit_tests/mprintf.tst
+++ b/scilab/modules/output_stream/tests/unit_tests/mprintf.tst
@@ -1,6 +1,7 @@
1// ============================================================================= 1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA 3// Copyright (C) 2008 - INRIA
4// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================= 7// =============================================================================
@@ -155,3 +156,33 @@ D = [ ..
155 34.936154 ]; 156 34.936154 ];
156 157
157mprintf("==>%10s : %08.4f %08.4f %08.4f<==\n\n",A,C,D); 158mprintf("==>%10s : %08.4f %08.4f %08.4f<==\n\n",A,C,D);
159
160// Booleans
161// =============================================================================
162n = [%pi ; %e];
163b = [%T ; %F];
164for f = ["d" "i" "u" "o" "x" "X" "g" "G"]
165 mprintf("%"+f+"\n", b);
166 mprintf("%"+f+" %d\n", b, n);
167 if and(f <> ["u" "o" "x" "X"]) // http://bugzilla.scilab.org/16563
168 mprintf("%2$"+f+" %1$d\n", n, b);
169 end
170end
171// %f
172msprintf("%f\n", b);
173mprintf("%f %d\n", b, n);
174mprintf("%2$f %1$d\n", n, b);
175// %e
176mprintf("%e\n", b);
177mprintf("%e %d\n", b, n);
178mprintf("%2$e %1$d\n", n, b);
179// %E
180mprintf("%E\n", b);
181mprintf("%E %d\n", b, n);
182mprintf("%2$E %1$d\n", n, b);
183// %s, %c
184for f = ["s" "c"]
185 mprintf("%"+f+"\n", b);
186 mprintf("%"+f+" %d\n", b, n);
187 mprintf("%2$"+f+" %1$d\n", n, b);
188end
diff --git a/scilab/modules/output_stream/tests/unit_tests/msprintf.tst b/scilab/modules/output_stream/tests/unit_tests/msprintf.tst
index 9fddf26..a9b7a6a 100644
--- a/scilab/modules/output_stream/tests/unit_tests/msprintf.tst
+++ b/scilab/modules/output_stream/tests/unit_tests/msprintf.tst
@@ -2,6 +2,7 @@
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA 3// Copyright (C) 2008 - INRIA
4// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS 4// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
5// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
5// 6//
6// This file is distributed under the same license as the Scilab package. 7// This file is distributed under the same license as the Scilab package.
7// ============================================================================= 8// =============================================================================
@@ -123,6 +124,7 @@ assert_checkequal(msprintf("%10s","text"), " text");
123assert_checkequal(msprintf("%10.3s","text"), " tex"); 124assert_checkequal(msprintf("%10.3s","text"), " tex");
124assert_checkequal(msprintf("%-10s","text"), "text "); 125assert_checkequal(msprintf("%-10s","text"), "text ");
125assert_checkequal(msprintf("%s","t"), "t"); 126assert_checkequal(msprintf("%s","t"), "t");
127assert_checkequal(msprintf("%s","éàöαβδ"), "éàöαβδ");
126 128
127// format '%x' 129// format '%x'
128// ============================================================================= 130// =============================================================================
@@ -210,3 +212,33 @@ refMsg = msprintf(_("%s: Wrong number of input arguments: data doesn''t fit with
210assert_checkerror("msprintf(""%2$d"", 1);", refMsg); 212assert_checkerror("msprintf(""%2$d"", 1);", refMsg);
211assert_checkerror("msprintf(""%d%1$d"", 1);", refMsg); 213assert_checkerror("msprintf(""%d%1$d"", 1);", refMsg);
212assert_checkerror("msprintf(""%1$d%d"", 1);", refMsg); 214assert_checkerror("msprintf(""%1$d%d"", 1);", refMsg);
215
216// Booleans
217// =============================================================================
218n = [%pi ; %e];
219b = [%T ; %F];
220for f = ["d" "i" "u" "o" "x" "X" "g" "G"]
221 assert_checkequal(msprintf("%"+f+"\n", b), ["1" ; "0"]);
222 assert_checkequal(msprintf("%"+f+" %d\n", b, n), ["1 3" ; "0 2"]);
223 if and(f <> ["u" "o" "x" "X"]) // http://bugzilla.scilab.org/16563
224 assert_checkequal(msprintf("%2$"+f+" %1$d\n", n, b), ["1 3" ; "0 2"]);
225 end
226end
227// %f
228assert_checkequal(msprintf("%f\n", b), ["1.000000" ; "0.000000"]);
229assert_checkequal(msprintf("%f %d\n", b, n), ["1.000000 3" ; "0.000000 2"]);
230assert_checkequal(msprintf("%2$f %1$d\n", n, b), ["1.000000 3" ; "0.000000 2"]);
231// %e
232assert_checkequal(msprintf("%e\n", b), ["1.000000e+00" ; "0.000000e+00"]);
233assert_checkequal(msprintf("%e %d\n", b, n), ["1.000000e+00 3" ; "0.000000e+00 2"]);
234assert_checkequal(msprintf("%2$e %1$d\n", n, b), ["1.000000e+00 3" ; "0.000000e+00 2"]);
235// %E
236assert_checkequal(msprintf("%E\n", b), ["1.000000E+00" ; "0.000000E+00"]);
237assert_checkequal(msprintf("%E %d\n", b, n), ["1.000000E+00 3" ; "0.000000E+00 2"]);
238assert_checkequal(msprintf("%2$E %1$d\n", n, b), ["1.000000E+00 3" ; "0.000000E+00 2"]);
239// %s, %c
240for f = ["s" "c"]
241 assert_checkequal(msprintf("%"+f+"\n", b), ["T" ; "F"]);
242 assert_checkequal(msprintf("%"+f+" %d\n", b, n), ["T 3" ; "F 2"]);
243 assert_checkequal(msprintf("%2$"+f+" %1$d\n", n, b), ["T 3" ; "F 2"]);
244end