Sha256: 9cd80bb0cb09955ebf5b08c1c7977d069f3ab01e42a4d18cbf91f4ee50dca2ef

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

require "test_helper"

describe "Querying for structs" do
  before(:all) do
    @structs_source = RbGCCXML.parse(full_dir("headers/structs.h")).namespaces("structs")
  end

  specify "can find all structs in a given namespace" do
    structs = @structs_source.structs
    structs.size.should == 3 

    @structs_source.structs("Test1").should_not be_nil
    @structs_source.structs("Test2").should_not be_nil
    @structs_source.structs("Test3").should_not be_nil
  end

  specify "can find structs within structs" do
    test1 = @structs_source.structs.find(:name => "Test1")
    test1.should_not be_nil
    
    inner1 = test1.structs("Inner1")
    inner1.should_not be_nil
    
    inner2 = inner1.structs("Inner1")
    inner2.should_not be_nil
  end
end

describe "Querying for struct constructors" do
  before(:all) do
    @structs_source = RbGCCXML.parse(full_dir("headers/structs.h")).namespaces("structs")
  end

  specify "should have a list of constructors" do
    test1 = @structs_source.structs.find(:name => "Test1")
    test1.constructors.size.should == 2

    test2 = @structs_source.structs.find(:name => "Test2")
    test2.constructors.size.should == 3
  end

  specify "constructors should have arguments" do
    test2 = @structs_source.structs.find(:name => "Test2")

    # GCC generated copy constructors
    copy = test2.constructors[0]
    copy.artificial?.should be_true

    default = test2.constructors[1]
    default.arguments.size.should == 0

    specific = test2.constructors[2]
    specific.arguments.size.should == 1
    specific.arguments[0].cpp_type.name.should == "int"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbgccxml-1.0.3 spec/structs_test.rb
rbgccxml-1.0.2 spec/structs_test.rb
rbgccxml-1.0.1 spec/structs_test.rb
rbgccxml-1.0 test/structs_test.rb