Sha256: 94d46c0ce2dcc5cc1ea8cc900ce2290debdbc61d790908a9332f9abcd315085b
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'rubygems' require 'coveralls' Coveralls.wear! 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) str.dup.force_encoding(Encoding::BINARY) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bindata-2.1.0 | test/common.rb |