зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Add test cases from SHA1 RFC and improve test failure message
I found that the current test cases did not cover the bitwise AND
performed on modified words after each iteration
(7e5765a66c/bundler/lib/bundler/digest.rb (L50)
)
https://github.com/rubygems/rubygems/commit/c8de819fee
This commit is contained in:
Родитель
1d924ae410
Коммит
eb5a01970f
|
@ -9,8 +9,15 @@ RSpec.describe Bundler::Digest do
|
|||
let(:stdlib) { ::Digest::SHA1 }
|
||||
|
||||
it "is compatible with stdlib" do
|
||||
["foo", "skfjsdlkfjsdf", "3924m", "ldskfj"].each do |payload|
|
||||
expect(subject.sha1(payload)).to be == stdlib.hexdigest(payload)
|
||||
random_strings = ["foo", "skfjsdlkfjsdf", "3924m", "ldskfj"]
|
||||
|
||||
# https://datatracker.ietf.org/doc/html/rfc3174#section-7.3
|
||||
rfc3174_test_cases = ["abc", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "a", "01234567" * 8]
|
||||
|
||||
(random_strings + rfc3174_test_cases).each do |payload|
|
||||
sha1 = subject.sha1(payload)
|
||||
sha1_stdlib = stdlib.hexdigest(payload)
|
||||
expect(sha1).to be == sha1_stdlib, "#{payload}'s sha1 digest (#{sha1}) did not match stlib's result (#{sha1_stdlib})"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче