[macruby-changes] [4588] MacRuby/trunk/spec/macruby/core/string_spec.rb
source_changes at macosforge.org
source_changes at macosforge.org
Thu Oct 7 17:43:37 PDT 2010
Revision: 4588
http://trac.macosforge.org/projects/ruby/changeset/4588
Author: lsansonetti at apple.com
Date: 2010-10-07 17:43:36 -0700 (Thu, 07 Oct 2010)
Log Message:
-----------
add specs for String#pointer
Modified Paths:
--------------
MacRuby/trunk/spec/macruby/core/string_spec.rb
Modified: MacRuby/trunk/spec/macruby/core/string_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/string_spec.rb 2010-10-08 00:40:48 UTC (rev 4587)
+++ MacRuby/trunk/spec/macruby/core/string_spec.rb 2010-10-08 00:43:36 UTC (rev 4588)
@@ -82,6 +82,17 @@
i += 1000
end
end
+
+ it "responds to #pointer which returns a Pointer wrapping the internal storage" do
+ s = 'hey'
+ ptr = s.pointer
+ 3.times do |i|
+ ptr[i].chr.should == s[i]
+ end
+ ptr.class.should == Pointer
+ s2 = NSString.alloc.initWithBytes(ptr, length: 3, encoding: NSASCIIStringEncoding)
+ s2.should == s
+ end
end
describe "An NSString object" do
@@ -115,7 +126,8 @@
[:ascii_only?, []],
[:bytes, []],
[:each_byte, []],
- [:to_data, []]].each do |msg, args|
+ [:to_data, []],
+ [:pointer, []]].each do |msg, args|
it "responds to ##{msg} but raises an exception" do
lambda { NSString.stringWithString('test').send(msg, *args) }.should raise_error(ArgumentError)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101007/dbb180b5/attachment.html>
More information about the macruby-changes
mailing list