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

Common: improve tests for cmdline

This commit is contained in:
Alex Kotov 2022-06-08 06:01:05 +03:00
parent 7f4cf20a56
commit 61a4247627
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 10 additions and 6 deletions

View file

@ -73,14 +73,16 @@ assert 'usign common tests' do
cmdline_yml = File.expand_path('../../../../common/cmdline.yml', __FILE__)
YAML.load(File.read(cmdline_yml)).each do |test|
next unless test['argv_count_max'].nil? && test['buffer_size'].nil?
escape_str = lambda do |str|
eval "\"#{str}\"", nil, __FILE__, __LINE__ # "str"
end
cmdline = escape_str.call test['cmdline']
result = test['result'].map(&escape_str)
argv_count_max = test['argv_count_max']
buffer_size = test['buffer_size']
result = test['result']&.map(&escape_str)
next unless argv_count_max.nil? && buffer_size.nil? && !result.nil?
assert "transforms #{cmdline.inspect} to #{result.inspect}" do
assert_equal KernAux.cmdline(cmdline), result

View file

@ -95,14 +95,16 @@ KernAux::Version.supports_cmdline? and RSpec.describe KernAux, '.cmdline' do
cmdline_yml = File.expand_path('../../../../../common/cmdline.yml', __dir__)
YAML.safe_load_file(cmdline_yml).each do |test|
next unless test['argv_count_max'].nil? && test['buffer_size'].nil?
escape_str = lambda do |str|
eval "\"#{str}\"", binding, __FILE__, __LINE__ # "str"
end
cmdline = escape_str.call test['cmdline']
result = test['result'].map(&escape_str)
argv_count_max = test['argv_count_max']
buffer_size = test['buffer_size']
result = test['result']&.map(&escape_str)
next unless argv_count_max.nil? && buffer_size.nil? && !result.nil?
it "transforms #{cmdline.inspect} to #{result.inspect}" do
expect(described_class.cmdline(cmdline)).to eq result