From 19324a30a17c6ea0b3d77d34160841ef90ce3ed1 Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Thu, 28 Apr 2011 15:09:41 +0200 Subject: set hierarchy n lib and spec directories --- spec/ecore/ecore_getopt_spec.rb | 276 ++++++++++++++++++++++++++++++++++++++++ spec/ecore_getopt_spec.rb | 276 ---------------------------------------- spec/eina/eina_list_spec.rb | 100 +++++++++++++++ spec/eina_list_spec.rb | 100 --------------- spec/evas_spec.rb | 2 +- 5 files changed, 377 insertions(+), 377 deletions(-) create mode 100644 spec/ecore/ecore_getopt_spec.rb delete mode 100644 spec/ecore_getopt_spec.rb create mode 100644 spec/eina/eina_list_spec.rb delete mode 100644 spec/eina_list_spec.rb (limited to 'spec') diff --git a/spec/ecore/ecore_getopt_spec.rb b/spec/ecore/ecore_getopt_spec.rb new file mode 100644 index 0000000..a296db7 --- /dev/null +++ b/spec/ecore/ecore_getopt_spec.rb @@ -0,0 +1,276 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +#require 'efl/ecore' +require 'efl/ecore/ecore_getopt' +# +describe Efl::EcoreGetopt do + # + before(:all) do + Efl::Ecore.init + # + @p = Efl::EcoreGetopt::Parser.new :prog =>"Prog", :usage => "Usage", :version => "0.0.0", :copyright => "less", :license => "MIT", :description => "description", :strict => 1 + @callback = Proc.new do |parser, desc, string, data, value| + parser.address.should eql @p.to_ptr.address + string.should eql "my_data" + data.read_string.should eql "cb_data" + value.read_pointer.read_int.should eql 99 + true + end + # + @values = { + :license => FFI::MemoryPointer.new(:uchar), + :copyright => FFI::MemoryPointer.new(:uchar), + :version => FFI::MemoryPointer.new(:uchar), + :help => FFI::MemoryPointer.new(:uchar), + :int => FFI::MemoryPointer.new(:int), + :double => FFI::MemoryPointer.new(:double), + :short => FFI::MemoryPointer.new(:short), + :long => FFI::MemoryPointer.new(:long), + :const => FFI::MemoryPointer.new(:int), + :true => FFI::MemoryPointer.new(:uchar), + :false => FFI::MemoryPointer.new(:uchar), + :choice => FFI::MemoryPointer.new(:pointer), + :count => FFI::MemoryPointer.new(:int), + :callback => FFI::MemoryPointer.new(:int), + } + @meta1 = FFI::MemoryPointer.from_string "My pretty" + @meta2 = FFI::MemoryPointer.from_string "My precious" + @cb_data = FFI::MemoryPointer.from_string "cb_data" + # + @p.license 'L', 'license' + @p.value :boolp, @values[:license] + @p.copyright 'C', 'copyright' + @p.value :boolp, @values[:copyright] + @p.version 'V', 'version' + @p.value :boolp, @values[:version] + @p.help 'H', 'help' + @p.value :boolp, @values[:help] + @p.store_type :int, 'i', 'int', 'store an integer' + @p.value :intp, @values[:int] + @p.store_meta_type :double, 'd', 'double', 'store an double+meta', @meta1 + @p.value :doublep, @values[:double] + @p.store_def_type :short, 's', 'short', 'store an short+default', 6 + @p.value :shortp, @values[:short] + @p.store_full_type :long, 'l', 'long', 'store a long+full', @meta2, :ecore_getopt_desc_arg_requirement_yes, 666 + @p.value :longp, @values[:long] + @p.store_const 'c', 'const', 'store a constant', 123456 + @p.value :intp, @values[:const] + @p.store_true 't', 'true', 'store true' + @p.value :boolp, @values[:false] + @p.store_false 'f', 'false', 'store false' + @p.value :boolp, @values[:true] + @p.choice 'm', 'many', 'store choice', ['ch1','ch2','ch3'] + @p.value :strp, @values[:choice] +# # FIXME: uses listp with Eina_List +# @p.append 'a', 'append', 'store append', :ecore_getopt_type_int + @p.count 'k', 'count', 'store count' + @p.value :intp, @values[:count] + @p.callback_args 'b', 'callback', 'callback full', @meta, @callback, @cb_data + @p.value :intp, @values[:callback] + @p.create +# puts @p.debug + # + end + before(:each) do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].write_char 0 + end + @values[:int].write_int 0 + @values[:double].write_double 3.1415926 + @values[:short].write_short 9 + @values[:long].write_long 666 + @values[:const].write_int -666 + @values[:true].write_uchar 1 + @values[:false].write_uchar 0 + @values[:choice].write_pointer FFI::Pointer::NULL + @values[:count].write_int 664 + @values[:callback].write_int 99 + end + after(:all) do + Efl::Ecore.shutdown + end + # + describe "license copyright version help" do + it "should handle -L" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["My lovely prog name","-L"] + @values[:license].read_char.should eql 1 + [ :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + it "should handle --license" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["My lovely prog name","--license"] + @values[:license].read_char.should eql 1 + [ :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + it "should handle -C" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["progname","-C"] + @values[:copyright].read_char.should eql 1 + [ :license, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + it "should handle --copyright" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["My lovely prog name","--copyright"] + @values[:copyright].read_char.should eql 1 + [ :license, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + it "should handle -V" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["My lovely prog name","-V"] + @values[:version].read_char.should eql 1 + [ :license, :copyright, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + it "should handle --version" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["progname","--version"] + @values[:version].read_char.should eql 1 + [ :license, :copyright, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + it "should handle -H" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["My lovely prog name","-H"] + @values[:help].read_char.should eql 1 + [ :license, :copyright, :version ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + it "should handle --help" do + [ :license, :copyright, :version, :help ].each do |sym| + @values[sym].read_char.should eql 0 + end + args = @p.parse ["progname","--help"] + @values[:help].read_char.should eql 1 + [ :license, :copyright, :version ].each do |sym| + @values[sym].read_char.should eql 0 + end + end + end + describe "simple short options" do + it "should handle -i" do + @values[:int].read_int.should eql 0 + args = @p.parse ["progname","-i 666"] + @values[:int].read_int.should eql 666 + end + it "should handle -d" do + @values[:double].read_double.should eql 3.1415926 + args = @p.parse ["progname","-d 6.66"] + @values[:double].read_double.should eql 6.66 + end + it "should handle -s" do + @values[:short].read_short.should eql 9 + args = @p.parse ["progname","-s 125"] + @values[:short].read_short.should eql 125 + end + it "should handle -l" do + @values[:long].read_long.should eql 666 + args = @p.parse ["progname","-l 69"] + @values[:long].read_long.should eql 69 + end + it "should handle -c" do + @values[:const].read_int.should eql -666 + args = @p.parse ["progname","-c"] + @values[:const].read_int.should eql 123456 + end + it "should handle -t" do + @values[:false].read_uchar.should eql 0 + args = @p.parse ["progname","-t"] + @values[:false].read_uchar.should eql 1 + end + it "should handle -f" do + @values[:true].read_uchar.should eql 1 + args = @p.parse ["progname","-f"] + @values[:true].read_uchar.should eql 0 + end + it "should handle -m" do + @values[:choice].read_pointer.should eql FFI::Pointer::NULL + args = @p.parse ["progname","-mch2"] + @values[:choice].read_pointer.read_string.should eql "ch2" + end + it "should handle -k" do + @values[:count].read_int.should eql 664 + args = @p.parse ["progname","-kk"] + @values[:count].read_int.should eql 666 + end + it "should handle -b" do + args = @p.parse ["progname","-bmy_data"] + end + end + describe "simple long options" do + it "should handle --int" do + @values[:int].read_int.should eql 0 + args = @p.parse ["progname","--int=666"] + @values[:int].read_int.should eql 666 + end + it "should handle --double" do + @values[:double].read_double.should eql 3.1415926 + args = @p.parse ["progname","--double=6.66"] + @values[:double].read_double.should eql 6.66 + end + it "should handle --short" do + @values[:short].read_short.should eql 9 + args = @p.parse ["progname","--short=125"] + @values[:short].read_short.should eql 125 + end + it "should handle --long" do + @values[:long].read_long.should eql 666 + args = @p.parse ["progname","--long=69"] + @values[:long].read_long.should eql 69 + end + it "should handle --const" do + @values[:const].read_int.should eql -666 + args = @p.parse ["progname","--const"] + @values[:const].read_int.should eql 123456 + end + it "should handle --true" do + @values[:false].read_uchar.should eql 0 + args = @p.parse ["progname","--true"] + @values[:false].read_uchar.should eql 1 + end + it "should handle --false" do + @values[:true].read_uchar.should eql 1 + args = @p.parse ["progname","--false"] + @values[:true].read_uchar.should eql 0 + end + it "should handle --many" do + @values[:choice].read_pointer.should eql FFI::Pointer::NULL + args = @p.parse ["progname","--many=ch3"] + @values[:choice].read_pointer.read_string.should eql "ch3" + end + it "should handle --count" do + @values[:count].read_int.should eql 664 + args = @p.parse ["progname","--count","--count"] + @values[:count].read_int.should eql 666 + end + it "should handle --callback" do + args = @p.parse ["progname","--callback=my_data"] + end + end +end diff --git a/spec/ecore_getopt_spec.rb b/spec/ecore_getopt_spec.rb deleted file mode 100644 index 6f5c7f0..0000000 --- a/spec/ecore_getopt_spec.rb +++ /dev/null @@ -1,276 +0,0 @@ -#! /usr/bin/env ruby -# -*- coding: UTF-8 -*- -# -require 'efl/ecore' -require 'efl/ecore_getopt' -# -describe Efl::EcoreGetopt do - # - before(:all) do - Efl::Ecore.init - # - @p = Efl::EcoreGetopt::Parser.new :prog =>"Prog", :usage => "Usage", :version => "0.0.0", :copyright => "less", :license => "MIT", :description => "description", :strict => 1 - @callback = Proc.new do |parser, desc, string, data, value| - parser.address.should eql @p.to_ptr.address - string.should eql "my_data" - data.read_string.should eql "cb_data" - value.read_pointer.read_int.should eql 99 - true - end - # - @values = { - :license => FFI::MemoryPointer.new(:uchar), - :copyright => FFI::MemoryPointer.new(:uchar), - :version => FFI::MemoryPointer.new(:uchar), - :help => FFI::MemoryPointer.new(:uchar), - :int => FFI::MemoryPointer.new(:int), - :double => FFI::MemoryPointer.new(:double), - :short => FFI::MemoryPointer.new(:short), - :long => FFI::MemoryPointer.new(:long), - :const => FFI::MemoryPointer.new(:int), - :true => FFI::MemoryPointer.new(:uchar), - :false => FFI::MemoryPointer.new(:uchar), - :choice => FFI::MemoryPointer.new(:pointer), - :count => FFI::MemoryPointer.new(:int), - :callback => FFI::MemoryPointer.new(:int), - } - @meta1 = FFI::MemoryPointer.from_string "My pretty" - @meta2 = FFI::MemoryPointer.from_string "My precious" - @cb_data = FFI::MemoryPointer.from_string "cb_data" - # - @p.license 'L', 'license' - @p.value :boolp, @values[:license] - @p.copyright 'C', 'copyright' - @p.value :boolp, @values[:copyright] - @p.version 'V', 'version' - @p.value :boolp, @values[:version] - @p.help 'H', 'help' - @p.value :boolp, @values[:help] - @p.store_type :int, 'i', 'int', 'store an integer' - @p.value :intp, @values[:int] - @p.store_meta_type :double, 'd', 'double', 'store an double+meta', @meta1 - @p.value :doublep, @values[:double] - @p.store_def_type :short, 's', 'short', 'store an short+default', 6 - @p.value :shortp, @values[:short] - @p.store_full_type :long, 'l', 'long', 'store a long+full', @meta2, :ecore_getopt_desc_arg_requirement_yes, 666 - @p.value :longp, @values[:long] - @p.store_const 'c', 'const', 'store a constant', 123456 - @p.value :intp, @values[:const] - @p.store_true 't', 'true', 'store true' - @p.value :boolp, @values[:false] - @p.store_false 'f', 'false', 'store false' - @p.value :boolp, @values[:true] - @p.choice 'm', 'many', 'store choice', ['ch1','ch2','ch3'] - @p.value :strp, @values[:choice] -# # FIXME: uses listp with Eina_List -# @p.append 'a', 'append', 'store append', :ecore_getopt_type_int - @p.count 'k', 'count', 'store count' - @p.value :intp, @values[:count] - @p.callback_args 'b', 'callback', 'callback full', @meta, @callback, @cb_data - @p.value :intp, @values[:callback] - @p.create -# puts @p.debug - # - end - before(:each) do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].write_char 0 - end - @values[:int].write_int 0 - @values[:double].write_double 3.1415926 - @values[:short].write_short 9 - @values[:long].write_long 666 - @values[:const].write_int -666 - @values[:true].write_uchar 1 - @values[:false].write_uchar 0 - @values[:choice].write_pointer FFI::Pointer::NULL - @values[:count].write_int 664 - @values[:callback].write_int 99 - end - after(:all) do - Efl::Ecore.shutdown - end - # - describe "license copyright version help" do - it "should handle -L" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["My lovely prog name","-L"] - @values[:license].read_char.should eql 1 - [ :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - it "should handle --license" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["My lovely prog name","--license"] - @values[:license].read_char.should eql 1 - [ :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - it "should handle -C" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["progname","-C"] - @values[:copyright].read_char.should eql 1 - [ :license, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - it "should handle --copyright" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["My lovely prog name","--copyright"] - @values[:copyright].read_char.should eql 1 - [ :license, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - it "should handle -V" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["My lovely prog name","-V"] - @values[:version].read_char.should eql 1 - [ :license, :copyright, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - it "should handle --version" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["progname","--version"] - @values[:version].read_char.should eql 1 - [ :license, :copyright, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - it "should handle -H" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["My lovely prog name","-H"] - @values[:help].read_char.should eql 1 - [ :license, :copyright, :version ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - it "should handle --help" do - [ :license, :copyright, :version, :help ].each do |sym| - @values[sym].read_char.should eql 0 - end - args = @p.parse ["progname","--help"] - @values[:help].read_char.should eql 1 - [ :license, :copyright, :version ].each do |sym| - @values[sym].read_char.should eql 0 - end - end - end - describe "simple short options" do - it "should handle -i" do - @values[:int].read_int.should eql 0 - args = @p.parse ["progname","-i 666"] - @values[:int].read_int.should eql 666 - end - it "should handle -d" do - @values[:double].read_double.should eql 3.1415926 - args = @p.parse ["progname","-d 6.66"] - @values[:double].read_double.should eql 6.66 - end - it "should handle -s" do - @values[:short].read_short.should eql 9 - args = @p.parse ["progname","-s 125"] - @values[:short].read_short.should eql 125 - end - it "should handle -l" do - @values[:long].read_long.should eql 666 - args = @p.parse ["progname","-l 69"] - @values[:long].read_long.should eql 69 - end - it "should handle -c" do - @values[:const].read_int.should eql -666 - args = @p.parse ["progname","-c"] - @values[:const].read_int.should eql 123456 - end - it "should handle -t" do - @values[:false].read_uchar.should eql 0 - args = @p.parse ["progname","-t"] - @values[:false].read_uchar.should eql 1 - end - it "should handle -f" do - @values[:true].read_uchar.should eql 1 - args = @p.parse ["progname","-f"] - @values[:true].read_uchar.should eql 0 - end - it "should handle -m" do - @values[:choice].read_pointer.should eql FFI::Pointer::NULL - args = @p.parse ["progname","-mch2"] - @values[:choice].read_pointer.read_string.should eql "ch2" - end - it "should handle -k" do - @values[:count].read_int.should eql 664 - args = @p.parse ["progname","-kk"] - @values[:count].read_int.should eql 666 - end - it "should handle -b" do - args = @p.parse ["progname","-bmy_data"] - end - end - describe "simple long options" do - it "should handle --int" do - @values[:int].read_int.should eql 0 - args = @p.parse ["progname","--int=666"] - @values[:int].read_int.should eql 666 - end - it "should handle --double" do - @values[:double].read_double.should eql 3.1415926 - args = @p.parse ["progname","--double=6.66"] - @values[:double].read_double.should eql 6.66 - end - it "should handle --short" do - @values[:short].read_short.should eql 9 - args = @p.parse ["progname","--short=125"] - @values[:short].read_short.should eql 125 - end - it "should handle --long" do - @values[:long].read_long.should eql 666 - args = @p.parse ["progname","--long=69"] - @values[:long].read_long.should eql 69 - end - it "should handle --const" do - @values[:const].read_int.should eql -666 - args = @p.parse ["progname","--const"] - @values[:const].read_int.should eql 123456 - end - it "should handle --true" do - @values[:false].read_uchar.should eql 0 - args = @p.parse ["progname","--true"] - @values[:false].read_uchar.should eql 1 - end - it "should handle --false" do - @values[:true].read_uchar.should eql 1 - args = @p.parse ["progname","--false"] - @values[:true].read_uchar.should eql 0 - end - it "should handle --many" do - @values[:choice].read_pointer.should eql FFI::Pointer::NULL - args = @p.parse ["progname","--many=ch3"] - @values[:choice].read_pointer.read_string.should eql "ch3" - end - it "should handle --count" do - @values[:count].read_int.should eql 664 - args = @p.parse ["progname","--count","--count"] - @values[:count].read_int.should eql 666 - end - it "should handle --callback" do - args = @p.parse ["progname","--callback=my_data"] - end - end -end diff --git a/spec/eina/eina_list_spec.rb b/spec/eina/eina_list_spec.rb new file mode 100644 index 0000000..2522256 --- /dev/null +++ b/spec/eina/eina_list_spec.rb @@ -0,0 +1,100 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/eina/eina_list' +# +describe Efl::Eina::EinaList do + # + before(:all) { + EinaList = Efl::Eina::EinaList + Efl::Eina.init.should eql 1 + } + after(:all) { + Efl::Eina.shutdown.should eql 0 + } + # + it "should append prepend and fetch" do + l = EinaList.new + d1 = ::FFI::MemoryPointer.from_string "D0" + d2 = ::FFI::MemoryPointer.from_string "D1" + d3 = ::FFI::MemoryPointer.from_string "D2" + d4 = ::FFI::MemoryPointer.from_string "D3" + l.append d3 + l.prepend d2 + l << d4 + l.unshift d1 + 0.upto 3 do |i| + l.nth(i).read_string.should eql "D#{i}" + end + l.each { |p| p.read_string.empty?.should be_false } + l.free + end + # + it "should be able to convert into ruby Array from NULL pointer" do + ary = Array.from_eina_list ::FFI::Pointer::NULL + ary.empty?.should be_true + ary.is_a?(Array).should be_true + end + # + it "should be able to convert into ruby Array from empty EinaList" do + ary = Array.from_eina_list EinaList.new + ary.empty?.should be_true + ary.is_a?(Array).should be_true + end + # + it "should be able to convert into ruby Array from empty EinaList pointer" do + ary = Array.from_eina_list EinaList.new.ptr + ary.empty?.should be_true + ary.is_a?(Array).should be_true + end + # + it "should be able to convert into ruby Array from non empty EinaList" do + l = EinaList.new + d1 = ::FFI::MemoryPointer.from_string "D0" + d2 = ::FFI::MemoryPointer.from_string "D1" + d3 = ::FFI::MemoryPointer.from_string "D2" + d4 = ::FFI::MemoryPointer.from_string "D3" + l.append d3 + l.prepend d2 + l << d4 + l.unshift d1 + ary = Array.from_eina_list l + ary.length.should eql 4 + 0.upto 3 do |i| + ary[i].read_string.should eql "D#{i}" + end + l.free + end + # + it "should be able to convert into ruby Array from non empty EinaList pointer" do + l = EinaList.new + d1 = ::FFI::MemoryPointer.from_string "D0" + d2 = ::FFI::MemoryPointer.from_string "D1" + d3 = ::FFI::MemoryPointer.from_string "D2" + d4 = ::FFI::MemoryPointer.from_string "D3" + l.append d3 + l.prepend d2 + l << d4 + l.unshift d1 + ary = Array.from_eina_list l.ptr + ary.length.should eql 4 + 0.upto 3 do |i| + ary[i].read_string.should eql "D#{i}" + end + l.free + end + # + it "should be able to build from ruby Array" do + a = [] + a << ::FFI::MemoryPointer.from_string("D0") + a << ::FFI::MemoryPointer.from_string("D1") + a << ::FFI::MemoryPointer.from_string("D2") + a << ::FFI::MemoryPointer.from_string("D3") + l = EinaList.new a + 0.upto 3 do |i| + l.nth(i).read_string.should eql "D#{i}" + end + l.free + end + # +end diff --git a/spec/eina_list_spec.rb b/spec/eina_list_spec.rb deleted file mode 100644 index 5dba1de..0000000 --- a/spec/eina_list_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -#! /usr/bin/env ruby -# -*- coding: UTF-8 -*- -# -require 'efl/eina_list' -# -describe Efl::Eina::EinaList do - # - before(:all) { - EinaList = Efl::Eina::EinaList - Efl::Eina.init.should eql 1 - } - after(:all) { - Efl::Eina.shutdown.should eql 0 - } - # - it "should append prepend and fetch" do - l = EinaList.new - d1 = ::FFI::MemoryPointer.from_string "D0" - d2 = ::FFI::MemoryPointer.from_string "D1" - d3 = ::FFI::MemoryPointer.from_string "D2" - d4 = ::FFI::MemoryPointer.from_string "D3" - l.append d3 - l.prepend d2 - l << d4 - l.unshift d1 - 0.upto 3 do |i| - l.nth(i).read_string.should eql "D#{i}" - end - l.each { |p| p.read_string.empty?.should be_false } - l.free - end - # - it "should be able to convert into ruby Array from NULL pointer" do - ary = Array.from_eina_list ::FFI::Pointer::NULL - ary.empty?.should be_true - ary.is_a?(Array).should be_true - end - # - it "should be able to convert into ruby Array from empty EinaList" do - ary = Array.from_eina_list EinaList.new - ary.empty?.should be_true - ary.is_a?(Array).should be_true - end - # - it "should be able to convert into ruby Array from empty EinaList pointer" do - ary = Array.from_eina_list EinaList.new.ptr - ary.empty?.should be_true - ary.is_a?(Array).should be_true - end - # - it "should be able to convert into ruby Array from non empty EinaList" do - l = EinaList.new - d1 = ::FFI::MemoryPointer.from_string "D0" - d2 = ::FFI::MemoryPointer.from_string "D1" - d3 = ::FFI::MemoryPointer.from_string "D2" - d4 = ::FFI::MemoryPointer.from_string "D3" - l.append d3 - l.prepend d2 - l << d4 - l.unshift d1 - ary = Array.from_eina_list l - ary.length.should eql 4 - 0.upto 3 do |i| - ary[i].read_string.should eql "D#{i}" - end - l.free - end - # - it "should be able to convert into ruby Array from non empty EinaList pointer" do - l = EinaList.new - d1 = ::FFI::MemoryPointer.from_string "D0" - d2 = ::FFI::MemoryPointer.from_string "D1" - d3 = ::FFI::MemoryPointer.from_string "D2" - d4 = ::FFI::MemoryPointer.from_string "D3" - l.append d3 - l.prepend d2 - l << d4 - l.unshift d1 - ary = Array.from_eina_list l.ptr - ary.length.should eql 4 - 0.upto 3 do |i| - ary[i].read_string.should eql "D#{i}" - end - l.free - end - # - it "should be able to build from ruby Array" do - a = [] - a << ::FFI::MemoryPointer.from_string("D0") - a << ::FFI::MemoryPointer.from_string("D1") - a << ::FFI::MemoryPointer.from_string("D2") - a << ::FFI::MemoryPointer.from_string("D3") - l = EinaList.new a - 0.upto 3 do |i| - l.nth(i).read_string.should eql "D#{i}" - end - l.free - end - # -end diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb index 6ef3cdb..03a9e61 100644 --- a/spec/evas_spec.rb +++ b/spec/evas_spec.rb @@ -256,7 +256,7 @@ describe Efl::Evas do a = ['/tmp1','/tmp2'] @e.evas_font_path_append a[1] @e.evas_font_path_prepend a[0] - require 'efl/eina_list' + require 'efl/eina/eina_list' Efl::Eina::EinaList.new(@e.evas_font_path_list).each_with_index do |p,i| p.read_string.should eql a[i] end -- cgit v1.2.3