blob: b0c0cd48ed00b7637d06b925bbffcc31062f7391 (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
require_relative 'spec_helper'
load_extension("typed_data")
describe "CApiAllocTypedSpecs (a class with an alloc func defined)" do
it "calls the alloc func" do
@s = CApiAllocTypedSpecs.new
@s.typed_wrapped_data.should == 42 # not defined in initialize
end
end
describe "CApiWrappedTypedStruct" do
before :each do
@s = CApiWrappedTypedStructSpecs.new
end
it "wraps and unwraps data" do
a = @s.typed_wrap_struct(1024)
@s.typed_get_struct(a).should == 1024
end
it "throws an exception for a wrong type" do
a = @s.typed_wrap_struct(1024)
lambda { @s.typed_get_struct_other(a) }.should raise_error(TypeError)
end
it "unwraps data for a parent type" do
a = @s.typed_wrap_struct(1024)
@s.typed_get_struct_parent(a).should == 1024
end
describe "RTYPEDATA" do
it "returns the struct data" do
a = @s.typed_wrap_struct(1024)
@s.typed_get_struct_rdata(a).should == 1024
end
it "can be used to change the wrapped struct" do
a = @s.typed_wrap_struct(1024)
@s.typed_change_struct(a, 100)
@s.typed_get_struct(a).should == 100
end
end
describe "DATA_PTR" do
it "returns the struct data" do
a = @s.typed_wrap_struct(1024)
@s.typed_get_struct_data_ptr(a).should == 1024
end
end
end
|