Skip to content

Commit 9626547

Browse files
committed
Removed random side effect testing
2 parents 72978f2 + 20a17ad commit 9626547

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

lib/bitarray.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
class BitArray
22
attr_reader :size
3+
attr_reader :field
34
include Enumerable
5+
46
VERSION = "0.0.5"
57
ELEMENT_WIDTH = 32
68

7-
def initialize(size, default_value = 0)
9+
def initialize(size, field = nil)
810
@size = size
9-
@field = Array.new(((size - 1) / ELEMENT_WIDTH) + 1, 0)
10-
@field.map!{|i| ~i} if (default_value == 1)
11+
@field = field || Array.new(((size - 1) / ELEMENT_WIDTH) + 1, 0)
1112
end
1213

1314
# Set a bit (1/0)

test/test_bitarray.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ def test_random_setting_and_unsetting
2929
end
3030
end
3131

32-
def test_random_side_effects
33-
ba2 = BitArray.new(@public_ba.size, 1)
34-
35-
on = (@public_ba.size / 2).times.collect do
36-
index = rand(@public_ba.size)
37-
@public_ba[index] = 1
38-
ba2[index] = 0
39-
index
40-
end
41-
#assert_equal(@public_ba.to_s, @public_ba.to_s_fast)
42-
43-
@public_ba.size.times do |i|
44-
assert_equal(@public_ba[i], on.include?(i) ? 1 : 0)
45-
assert_equal(ba2[i], on.include?(i) ? 0 : 1)
46-
end
47-
end
32+
#def test_random_side_effects
33+
# ba2 = BitArray.new(@public_ba.size, 1)
34+
#
35+
# on = (@public_ba.size / 2).times.collect do
36+
# index = rand(@public_ba.size)
37+
# @public_ba[index] = 1
38+
# ba2[index] = 0
39+
# index
40+
# end
41+
# #assert_equal(@public_ba.to_s, @public_ba.to_s_fast)
42+
#
43+
# @public_ba.size.times do |i|
44+
# assert_equal(@public_ba[i], on.include?(i) ? 1 : 0)
45+
# assert_equal(ba2[i], on.include?(i) ? 0 : 1)
46+
# end
47+
#end
4848

4949
def test_multiple_setting
5050
1.upto(999) do |pos|

0 commit comments

Comments
 (0)