|
| 1 | +require 'spec_helper' |
| 2 | +require 'cache' |
| 3 | + |
| 4 | +describe GapFinder do |
| 5 | + |
| 6 | + it 'returns no gaps for empty data' do |
| 7 | + GapFinder.find(nil, nil).should be_nil |
| 8 | + end |
| 9 | + |
| 10 | + it 'returns no gaps with one element' do |
| 11 | + GapFinder.find([1], [1]).should be_nil |
| 12 | + end |
| 13 | + |
| 14 | + it 'returns no gaps when all elements are present' do |
| 15 | + GapFinder.find([1,2,3], [1,2,3]).should be_nil |
| 16 | + end |
| 17 | + |
| 18 | + it 'returns a single element gap' do |
| 19 | + GapFinder.find([1,3], [1,2,3]).should == {3 => [2]} |
| 20 | + end |
| 21 | + |
| 22 | + it 'returns a gap when one is present' do |
| 23 | + GapFinder.find([1,2,3,6,7], [1,2,3,4,5,6,7]).should == {6 => [4, 5]} |
| 24 | + end |
| 25 | + |
| 26 | + it 'returns multiple gaps' do |
| 27 | + GapFinder.find([1,5,6,7,10], [1,2,3,4,5,6,7,8,9,10]).should == {5 => [2,3,4], 10 => [8, 9]} |
| 28 | + end |
| 29 | + |
| 30 | + it 'returns a gap in the beginning' do |
| 31 | + GapFinder.find([2,3,4], [1,2,3,4]).should == {2 => [1]} |
| 32 | + end |
| 33 | + |
| 34 | + it 'returns a gap in the ending' do |
| 35 | + GapFinder.find([1,2,3], [1,2,3,4]).should == {4 => [4]} |
| 36 | + end |
| 37 | + |
| 38 | + it 'returns a large gap in the ending' do |
| 39 | + GapFinder.find([1,2,3], [1,2,3,4,5,6]).should == {6 => [4,5,6]} |
| 40 | + end |
| 41 | + |
| 42 | +end |
0 commit comments