File: bit_masks_spec.rb

package info (click to toggle)
ruby-ffi-bit-masks 0.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 148 kB
  • sloc: ruby: 232; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'spec_helper'
require 'ffi/bit_masks'

describe FFI::BitMasks do
  it "should have a VERSION constant" do
    expect(subject.const_get('VERSION')).not_to be_empty
  end

  describe "#bit_mask" do
    subject do
      mod = Module.new
      mod.extend FFI::Library
      mod.extend FFI::BitMasks
    end

    let(:flags) { {:foo => 0x1, :bar => 0x2, :baz => 0x4} }

    it "should return a BitMask object" do
      expect(subject.bit_mask(:flags,flags).flags).to eq(flags)
    end

    it "should define a typedef for the bitmask" do
      bitmask = subject.bit_mask(:flags,flags)

      expect(subject.find_type(:flags)).to be_kind_of(FFI::Type::Mapped)
    end
  end
end