Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rspec'
- require_relative 'base'
- describe Base do
- describe '#smallest' do
- it do
- expect(subject.smallest('1')).to eq('base 2 => 1')
- end
- it do
- expect(subject.smallest(21)).to eq('base 3 => 7')
- end
- it do
- expect(subject.smallest('ab3')).to eq('base 12 => 1575')
- end
- it do
- expect(subject.smallest('ff')).to eq('base 16 => 255')
- end
- it do
- expect(subject.smallest(0)).to eq('base 1 => 0')
- end
- end
- describe '#to_dec' do
- it do
- expect(subject.to_dec('66', 8)).to eq(54)
- end
- it do
- expect(subject.to_dec(11011, 2)).to eq(27)
- end
- it do
- expect(subject.to_dec('500', 10)).to eq(500)
- end
- end
- describe '#all_bases' do
- it do
- expected = 'base 3 => 7
- base 4 => 9
- base 5 => 11
- base 6 => 13
- base 7 => 15
- base 8 => 17
- base 9 => 19
- base 10 => 21
- base 11 => 23
- base 12 => 25
- base 13 => 27
- base 14 => 29
- base 15 => 31
- base 16 => 33'
- expect(subject.all_bases(21)).to eq(expected)
- end
- it do
- expected = 'base 1 => 0
- base 2 => 0
- base 3 => 0
- base 4 => 0
- base 5 => 0
- base 6 => 0
- base 7 => 0
- base 8 => 0
- base 9 => 0
- base 10 => 0
- base 11 => 0
- base 12 => 0
- base 13 => 0
- base 14 => 0
- base 15 => 0
- base 16 => 0'
- expect(subject.all_bases(0)).to eq(expected)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement