test/bits_test.rb in bindata-2.4.13 vs test/bits_test.rb in bindata-2.4.14

- old
+ new

@@ -4,53 +4,53 @@ module AllBitfields def test_has_a_sensible_value_of_zero all_objects do |obj, nbits| - obj.must_equal 0 + _(obj).must_equal 0 end end def test_avoids_underflow all_objects do |obj, nbits| obj.assign(min_value - 1) - obj.must_equal min_value + _(obj).must_equal min_value end end def test_avoids_overflow all_objects do |obj, nbits| obj.assign(max_value + 1) - obj.must_equal max_value + _(obj).must_equal max_value end end def test_assign_values all_objects do |obj, nbits| some_values_within_range.each do |val| obj.assign(val) - obj.must_equal val + _(obj).must_equal val end end end def test_assign_values_from_other_bit_objects all_objects do |obj, nbits| some_values_within_range.each do |val| obj.assign(obj.new(val)) - obj.must_equal val + _(obj).must_equal val end end end def test_symmetrically_read_and_write all_objects do |obj, nbits| some_values_within_range.each do |val| obj.assign(val) other = obj.new other.read(obj.to_binary_s) - other.must_equal obj + _(other).must_equal obj end end end def all_objects(&block) @@ -128,11 +128,11 @@ all_objects do |obj, nbits| nbytes = (nbits + 7) / 8 str = [0b1000_0000].pack("C") + "\000" * (nbytes - 1) obj.read(str) - obj.must_equal 1 << (nbits - 1) + _(obj).must_equal 1 << (nbits - 1) end end end describe "Signed big endian bitfields" do @@ -147,11 +147,11 @@ all_objects do |obj, nbits| nbytes = (nbits + 7) / 8 str = [0b0100_0000].pack("C") + "\000" * (nbytes - 1) obj.read(str) - obj.must_equal 1 << (nbits - 2) + _(obj).must_equal 1 << (nbits - 2) end end end describe "Unsigned little endian bitfields" do @@ -166,11 +166,11 @@ all_objects do |obj, nbits| nbytes = (nbits + 7) / 8 str = [0b0000_0001].pack("C") + "\000" * (nbytes - 1) obj.read(str) - obj.must_equal 1 + _(obj).must_equal 1 end end end describe "Signed little endian bitfields" do @@ -185,11 +185,11 @@ all_objects do |obj, nbits| nbytes = (nbits + 7) / 8 str = [0b0000_0001].pack("C") + "\000" * (nbytes - 1) obj.read(str) - obj.must_equal 1 + _(obj).must_equal 1 end end end describe "Bits of size 1" do @@ -197,35 +197,35 @@ it "accept true as value" do bit_classes.each do |bit_class| obj = bit_class.new obj.assign(true) - obj.must_equal 1 + _(obj).must_equal 1 end end it "accept false as value" do bit_classes.each do |bit_class| obj = bit_class.new obj.assign(false) - obj.must_equal 0 + _(obj).must_equal 0 end end it "accept nil as value" do bit_classes.each do |bit_class| obj = bit_class.new obj.assign(nil) - obj.must_equal 0 + _(obj).must_equal 0 end end it "must not be signed" do - lambda { + _ { BinData::Sbit1 }.must_raise RuntimeError - lambda { + _ { BinData::Sbit1le }.must_raise RuntimeError end end