## spec

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

context "Ruby C array functions" do
setup do
declare do |vars|
vars :VALUE, :ary
end

specify "rb_ary_new should create a new array of default size" do
%(
VALUE ary = rb_ary_new();
assert_type(ary, VALUE);
assert (rb_ary_size(ary), 16)
)
end

specify "rb_ary_new should create a new array of default size" do
decl VALUE, ary
ary = spec.rb_ary_new
spec.declare :VALUE, :ary
spec.call(:rb_ary_new).should be_equal(int 16)
end

specify "rb_ary_new should create a new array of default size" do
declare :VALUE, :ary
declare :int, :size => 2

assign ary, call.rb_ary_new2(size)
ary.should_not be_nil
call.rb_ary_size(ary).should be_equal(16)
end


specify "rb_ary_new2 should create a new array of the specified size" do
declare :ary, :VALUE
declare :size, :int

size = 100
ary = call.rb_ary_new2(size)
ary.should_not be_nil
call.rb_ary_size(ary).should == size
end


specify "rb_some_func should receive a foo structure and return something" do
declare :size => int, :field1 => double, :field2 => char(5)
end
end

## C file

#include "cspec.h"

void context_one_context_setup(void) {
...
}

void context_one_context_teardown(void) {
...
}

void context_one_setup(void) {
...
}

void context_one_teardown(void) {
...
}

void context_one(ContextRunner *runner) {
context_one_setup();
cspec_context_runner()
context_one_teardown();
}

void test_context_one_test_one(void) {

...
}

void test_context_one_test_one(void) {
...
}


int main(int argc, char *argv[]) {
cspec_runner(argc, argv);
}