Mercurial > vim
comparison src/testdir/test_expr.vim @ 26264:ce6490cd6282 v8.2.3663
patch 8.2.3663: using %S in printf() does not work correctly
Commit: https://github.com/vim/vim/commit/1f2453fec6f8f0f315f00ca7b562a02090cb1e37
Author: presuku <presuku@users.noreply.github.com>
Date: Wed Nov 24 15:32:57 2021 +0000
patch 8.2.3663: using %S in printf() does not work correctly
Problem: Using %S in printf() does not work correctly.
Solution: Fix the problem and add more tests. (closes https://github.com/vim/vim/issues/9208)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 24 Nov 2021 16:45:03 +0100 |
parents | 2093cc976da8 |
children | bf1a7ce3f14a |
comparison
equal
deleted
inserted
replaced
26263:96a2fb08d98a | 26264:ce6490cd6282 |
---|---|
299 | 299 |
300 call assert_equal('[ あいう]', printf('[%10.6S]', 'あいうえお')) | 300 call assert_equal('[ あいう]', printf('[%10.6S]', 'あいうえお')) |
301 call assert_equal('[ あいうえ]', printf('[%10.8S]', 'あいうえお')) | 301 call assert_equal('[ あいうえ]', printf('[%10.8S]', 'あいうえお')) |
302 call assert_equal('[あいうえお]', printf('[%10.10S]', 'あいうえお')) | 302 call assert_equal('[あいうえお]', printf('[%10.10S]', 'あいうえお')) |
303 call assert_equal('[あいうえお]', printf('[%10.12S]', 'あいうえお')) | 303 call assert_equal('[あいうえお]', printf('[%10.12S]', 'あいうえお')) |
304 | |
305 call assert_equal('あいう', printf('%S', 'あいう')) | |
306 call assert_equal('あいう', printf('%#S', 'あいう')) | |
307 | |
308 call assert_equal('あb', printf('%2S', 'あb')) | |
309 call assert_equal('あb', printf('%.4S', 'あb')) | |
310 call assert_equal('あ', printf('%.2S', 'あb')) | |
311 call assert_equal(' あb', printf('%4S', 'あb')) | |
312 call assert_equal('0あb', printf('%04S', 'あb')) | |
313 call assert_equal('あb ', printf('%-4S', 'あb')) | |
314 call assert_equal('あ ', printf('%-4.2S', 'あb')) | |
315 | |
316 call assert_equal('aい', printf('%2S', 'aい')) | |
317 call assert_equal('aい', printf('%.4S', 'aい')) | |
318 call assert_equal('a', printf('%.2S', 'aい')) | |
319 call assert_equal(' aい', printf('%4S', 'aい')) | |
320 call assert_equal('0aい', printf('%04S', 'aい')) | |
321 call assert_equal('aい ', printf('%-4S', 'aい')) | |
322 call assert_equal('a ', printf('%-4.2S', 'aい')) | |
323 | |
324 call assert_equal('[あいう]', printf('[%05S]', 'あいう')) | |
325 call assert_equal('[あいう]', printf('[%06S]', 'あいう')) | |
326 call assert_equal('[0あいう]', printf('[%07S]', 'あいう')) | |
327 | |
328 call assert_equal('[あiう]', printf('[%05S]', 'あiう')) | |
329 call assert_equal('[0あiう]', printf('[%06S]', 'あiう')) | |
330 call assert_equal('[00あiう]', printf('[%07S]', 'あiう')) | |
331 | |
332 call assert_equal('[0あい]', printf('[%05.4S]', 'あいう')) | |
333 call assert_equal('[00あい]', printf('[%06.4S]', 'あいう')) | |
334 call assert_equal('[000あい]', printf('[%07.4S]', 'あいう')) | |
335 | |
336 call assert_equal('[00あi]', printf('[%05.4S]', 'あiう')) | |
337 call assert_equal('[000あi]', printf('[%06.4S]', 'あiう')) | |
338 call assert_equal('[0000あi]', printf('[%07.4S]', 'あiう')) | |
339 | |
340 call assert_equal('[0あい]', printf('[%05.5S]', 'あいう')) | |
341 call assert_equal('[00あい]', printf('[%06.5S]', 'あいう')) | |
342 call assert_equal('[000あい]', printf('[%07.5S]', 'あいう')) | |
343 | |
344 call assert_equal('[あiう]', printf('[%05.5S]', 'あiう')) | |
345 call assert_equal('[0あiう]', printf('[%06.5S]', 'あiう')) | |
346 call assert_equal('[00あiう]', printf('[%07.5S]', 'あiう')) | |
347 | |
348 call assert_equal('[0000000000]', printf('[%010.0S]', 'あいう')) | |
349 call assert_equal('[0000000000]', printf('[%010.1S]', 'あいう')) | |
350 call assert_equal('[00000000あ]', printf('[%010.2S]', 'あいう')) | |
351 call assert_equal('[00000000あ]', printf('[%010.3S]', 'あいう')) | |
352 call assert_equal('[000000あい]', printf('[%010.4S]', 'あいう')) | |
353 call assert_equal('[000000あい]', printf('[%010.5S]', 'あいう')) | |
354 call assert_equal('[0000あいう]', printf('[%010.6S]', 'あいう')) | |
355 call assert_equal('[0000あいう]', printf('[%010.7S]', 'あいう')) | |
356 | |
357 call assert_equal('[0000000000]', printf('[%010.1S]', 'あiう')) | |
358 call assert_equal('[00000000あ]', printf('[%010.2S]', 'あiう')) | |
359 call assert_equal('[0000000あi]', printf('[%010.3S]', 'あiう')) | |
360 call assert_equal('[0000000あi]', printf('[%010.4S]', 'あiう')) | |
361 call assert_equal('[00000あiう]', printf('[%010.5S]', 'あiう')) | |
362 call assert_equal('[00000あiう]', printf('[%010.6S]', 'あiう')) | |
363 call assert_equal('[00000あiう]', printf('[%010.7S]', 'あiう')) | |
304 | 364 |
305 call assert_equal('1%', printf('%d%%', 1)) | 365 call assert_equal('1%', printf('%d%%', 1)) |
306 endfunc | 366 endfunc |
307 | 367 |
308 function Test_printf_float() | 368 function Test_printf_float() |