From c19ff164cf420ae288456287318721bf6522c528 Mon Sep 17 00:00:00 2001 From: alpaca-tc Date: Mon, 1 Apr 2024 11:17:10 +0900 Subject: [PATCH] Fixed bug bit_id_to_ids --- lib/diver_down/web/bit_id.rb | 2 +- spec/diver_down/web/bit_id_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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