Sha256: 98c3e23ba98d1f5970d908d3f9a988fd384478561ac4eb7ac28c8bfe31c03907

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require File.dirname(__FILE__) + '/../test_helper.rb'

require 'ostruct'

class TestBase < Test::Unit::TestCase

  def setup
  end

  class ClassIncludeOnly
    include StructPacking::Base
  end
  
  def test_null_internal_format
    obj = ClassIncludeOnly.new
    assert_equal({}, obj.internal_format())
  end
  

  class SingleIntStruct
    include StructPacking::Base
    self.byte_format = "int hoge;"
  end
  
  def test_single_int_internal_format
    assert_equal("int" , SingleIntStruct.internal_format[:hoge])
  end

  class MultiFieldStruct
    include StructPacking::Base
    self.byte_format = "int fuga; char piyo"
  end

  def test_multi_field_internal_format
    assert_equal("int" , MultiFieldStruct.internal_format[:fuga])
    assert_equal("char" , MultiFieldStruct.internal_format[:piyo])
  end

=begin
  def test_internal_format_not_modifiable
    assert_equal(4, (SingleIntStruct.internal_format[:hoge])[:size])
    (SingleIntStruct.internal_format[:hoge])[:size] = 8
    assert_equal(8, (SingleIntStruct.internal_format[:hoge])[:size])
    assert_equal({:type=>"int", :start=>0, :size=>4} , SingleIntStruct.internal_format[:hoge])
  end
=end 
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
struct_packing-0.0.2 test/struct_packing/test_base.rb