test/test_blocker.rb in binaryparse-0.2.2 vs test/test_blocker.rb in binaryparse-0.2.3

- old
+ new

@@ -496,6 +496,26 @@ buf = "Name Last " ss = BBSubClass.new(buf) assert(ss) #assert_equal("Name", ss.name) end + + class BBTimeHHMM < BinaryBlocker::Blocker + has_one :now, :time_hhmm + end + + def test_packed_datetime_hhmm + now = Time.local(1985, 5, 30, 7, 6, 5) + b = BBTimeHHMM.new + b.now = now + + buf = b.block + assert_equal(12 / 2, buf.size) + + b2 = BBTimeHHMM.new(buf) + assert_not_equal(now, b2.now) + + now = Time.local(1985, 5, 30, 7, 6, 0) + assert_equal(now, b2.now) + end + end