Skip to content

Commit

Permalink
Fixed bug bit_id_to_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
alpaca-tc committed Apr 1, 2024
1 parent c91bccf commit c19ff16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/diver_down/web/bit_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions spec/diver_down/web/bit_id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c19ff16

Please sign in to comment.