1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00

Ruby: add original tests for KernAux.sprintf

This commit is contained in:
Alex Kotov 2022-01-23 01:20:46 +05:00
parent 1c0b69bc63
commit 8a8cb55be7
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -189,6 +189,21 @@ RSpec.describe KernAux, '.sprintf' do
['| 10| |10| | 10|', ['|%5d| ', 10], ['|%-2d|', 10], [' |%5d|', 10]],
['| 9| |9 | | 9|', ['|%5d| ', 9], ['|%-12d|', 9], [' |%5d|', 9]],
['| 10| |10 | | 10|', ['|%5d| ', 10], ['|%-12d|', 10], [' |%5d|', 10]],
# width 0-20
['Hello ', ['%0-20s', 'Hello']],
['1024 ', ['%0-20d', 1024]],
['-1024 ', ['%0-20d', -1024]],
['1024 ', ['%0-20i', 1024]],
['-1024 ', ['%0-20i', -1024]],
['1024 ', ['%0-20u', 1024]],
['4294966272 ', ['%0-20u', 4_294_966_272]],
['777 ', ['%0-20o', 511]],
['37777777001 ', ['%0-20o', 4_294_966_785]],
['1234abcd ', ['%0-20x', 305_441_741]],
['edcb5433 ', ['%0-20x', 3_989_525_555]],
['1234ABCD ', ['%0-20X', 305_441_741]],
['EDCB5433 ', ['%0-20X', 3_989_525_555]],
['x ', ['%0-20c', 'x']],
].each do |expected, *args|
it "transforms #{args.inspect} to #{expected.inspect}" do
expect(described_class.sprintf(*args)).to eq expected