Sha256: 6884db202d4de045d14e7fe297e0121fc6b60f94bcb90477d19ae9d95be31e80
Contents?: true
Size: 1.56 KB
Versions: 4
Compression:
Stored size: 1.56 KB
Contents
require 'rubygems' require 'minitest/autorun' require 'stringio' $LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__)) require 'bindata' class Object def expose_methods_for_testing cls = (Class === self) ? self : (class << self ; self; end) private_method_names = cls.private_instance_methods - Object.private_instance_methods cls.send(:public, *private_method_names) protected_method_names = cls.protected_instance_methods - Object.protected_instance_methods cls.send(:public, *protected_method_names) end def value_read_from_written self.class.read(self.to_binary_s) end end class StringIO # Returns the value that was written to the io def value rewind read end end class ExampleSingle < BinData::BasePrimitive def self.io_with_value(val) StringIO.new([val].pack("V")) end private def value_to_binary_string(val) [val].pack("V") end def read_and_return_value(io) io.readbytes(4).unpack("V").at(0) end def sensible_default 0 end end def binary(str) if str.respond_to?(:force_encoding) str.dup.force_encoding(Encoding::BINARY) else str end end module Kernel def must_raise_on_line(exp, line, msg = nil) ex = self.must_raise exp ex.message.must_equal msg if msg idx = ex.backtrace.find_index { |bt| /:in `must_raise_on_line'$/ =~ bt } line_num_regex = /.*:(\d+)(:.*|$)/ err_line = line_num_regex.match(ex.backtrace[0])[1].to_i ref_line = line_num_regex.match(ex.backtrace[idx + 1])[1].to_i (err_line - ref_line).must_equal line end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
bindata-1.8.3 | test/common.rb |
bindata-1.8.2 | test/common.rb |
bindata-1.8.1 | test/common.rb |
bindata-1.8.0 | test/common.rb |