Skip to content

Commit

Permalink
Cleanup test vector code
Browse files Browse the repository at this point in the history
  • Loading branch information
jtdowney committed Sep 19, 2014
1 parent 6067d3c commit 6567f7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
File renamed without changes.
16 changes: 8 additions & 8 deletions spec/spec_helper.rb
Expand Up @@ -5,19 +5,19 @@
end

def test_vectors
test_lines = File.readlines('spec/test_vectors.txt').map(&:strip).reject(&:empty?)
test_parts = File.readlines('spec/fixtures/test_vectors.txt').
map(&:strip).
reject(&:empty?).
each_slice(8)

vectors = {}
test_lines.each_slice(8) do |lines|
test_parts.reduce({}) do |vectors, lines|
name = lines.shift
values = lines.inject({}) do |hash, line|
values = lines.reduce({}) do |hash, line|
key, value = line.split('=').map(&:strip)
value = '' unless value
value = [value.slice(2..-1)].pack('H*') if value.start_with?('0x')
hash[key.to_sym] = value
hash
hash.merge(key.to_sym => value)
end
vectors[name] = values
vectors.merge(name => values)
end
vectors
end

0 comments on commit 6567f7e

Please sign in to comment.