diff --git a/lib/diver_down/web/bit_id.rb b/lib/diver_down/web/bit_id.rb index 4b7f228..912544d 100644 --- a/lib/diver_down/web/bit_id.rb +++ b/lib/diver_down/web/bit_id.rb @@ -18,7 +18,7 @@ def bit_id_to_ids(bit_id) ids = [] shift = 0 while bit_id.positive? - if bit_id & 1 + if (bit_id & 1) == 1 ids.push(shift + 1) end diff --git a/spec/diver_down/web/bit_id_spec.rb b/spec/diver_down/web/bit_id_spec.rb index 2f7a59c..7d9e5e9 100644 --- a/spec/diver_down/web/bit_id_spec.rb +++ b/spec/diver_down/web/bit_id_spec.rb @@ -23,6 +23,13 @@ expect(described_class.bit_id_to_ids(int_or)).to eq(ids) end + + it 'converts given specific bit_id to id' do + id = 1922 + bit_id = described_class.ids_to_bit_id([id]) + + expect(described_class.bit_id_to_ids(bit_id)).to eq([id]) + end end end end