Sha256: cf002265f0eb7e1576b508d613fd7e1f6df9bbbc0441e440a097e94479103c15
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
require 'spec_helper' module Darkholme describe Bitset do subject { Bitset.new } let(:bit) { 3 } it "can set bits" do subject.set(bit) expect(subject.set?(bit)).to eq(true) end it "can set bits to false" do subject.set(bit) expect(subject.set?(bit)).to eq(true) subject.set(bit, false) expect(subject.set?(bit)).to eq(false) end it "has a list of set indexes" do subject.set(3) subject.set(4) subject.set(5) expect(subject.set_indexes).to match_array([3, 4, 5]) end it "can clear bits" do subject.set(bit) expect(subject.set?(bit)).to eq(true) expect { subject.clear(bit) }.to change { subject.bits } expect(subject.set?(bit)).to eq(false) end it "removes the set index during a clear" do subject.set(bit) expect(subject.set_indexes).to include(bit) subject.clear(bit) expect(subject.set_indexes).to be_empty end it "can check for bit set status via array operators" do subject.set(bit) expect(subject[bit]).to eq(true) end it "can set bits via array operator" do subject[bit] = true expect(subject.set?(bit)).to eq(true) end it "can be compared to other bitsets" do other = Bitset.new(bit) subject.set(bit) expect(subject).to eq(other) end it "can check for complete inclusion of other bitsets" do subject.set(3) subject.set(4) subject.set(5) other = Bitset.new other.set(4) other.set(5) expect(subject.include? other).to eq(true) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
darkholme-1.0.0 | spec/lib/darkholme/bitset_spec.rb |
darkholme-0.9.1 | spec/lib/darkholme/bitset_spec.rb |
darkholme-0.9.0 | spec/lib/darkholme/bitset_spec.rb |