[Win32utils-devel] win32-clipboard encoding issue

Heesob Park phasis at gmail.com
Sat Jan 11 14:09:50 UTC 2014


Hi,

2014/1/11 Daniel Berger <djberg96 at gmail.com>:
> Hi,
>
> On Fri, Jan 10, 2014 at 9:04 PM, Heesob Park <phasis at gmail.com> wrote:
>>
>> Hi,
>>
>>
>> 2014/1/11 Daniel Berger <djberg96 at gmail.com>:
>> > Hi all,
>> >
>> > I've just about got win32-clipboard 0.6.0 done. There's one test failure
>> > (ffi branch), on some non-ascii text. I don't know if it's an encoding
>> > issue
>> > or just a bad test. I hate encoding issues. If someone else could take a
>> > look, that would be great.
>> >
>> I have two test failures with win32-clipboard 0.6.0.
>> =======================================================
>> Failure:
>> test: format_name returns expected value(TC_Win32_ClipBoard)
>> test_clipboard.rb:133:in `block in <class:TC_Win32_ClipBoard>'
>>      130:   end
>>      131:
>>      132:   test "format_name returns expected value" do
>>   => 133:     assert_equal("HTML Format", Clipboard.format_name(49422))
>>      134:     assert_nil(Clipboard.format_name(9999999))
>>      135:   end
>>      136:
>> <"HTML Format">(UTF-8) expected but was
>> <"XCPTimerClass">(ASCII-8BIT)
>>
>
> <snip>
>
>>
>> =======================================================
>> I think the first failure is due to the number 49422 is not a correct
>> value of HTML Format in my case.
>
>
> Interestingly, this passes on my system, though I had to change the test
> from 0.5.x to make it pass. I guess the exact format value is not
> necessarily the same across systems? Or maybe it's different on a different
> OS? I'm not sure, but I can update the test to be more generic.
>
In my case, CF_HTML is 49352.
I suggest to update like this:
format = Win32::Clipboard.register_format('HTML Format')
assert_equal("HTML Format", Clipboard.format_name(format))


> BTW, I am getting intermittent test failures for the
> HtmlClipboard.data_details method for some reason. It usually passes, but
> sometimes it doesn't:
>
> C:\Users\djberge\Repositories\win32-clipboard>rake
> C:/ruby200-x64/bin/ruby.exe -w -I"lib"
> -I"C:/ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib" "C:/ruby200
> -x64/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_test_loader.rb"
> "test/test*.rb"
> Loaded suite
> C:/ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_test_loader
> Started
> .F
> ===============================================================================
> Failure:
>   Exception raised:
>   RuntimeError(<failed to match block markers>)
> test: data details basic functionality(TC_Html_Clipboard)
> C:/Users/djberge/Repositories/win32-clipboard/test/test_html_clipboard.rb:42:in
> `block in <class:TC_Html_Clipb
> oard>'
>      39:
>      40:   test "data details basic functionality" do
>      41:     assert_respond_to(HtmlClipboard, :data_details)
>   => 42:     assert_nothing_raised{ HtmlClipboard.data_details }
>      43:     assert_kind_of(String, HtmlClipboard.data_details)
>      44:   end
>      45:
> ==============================================================
>
I can not reproduce the above test failure.

The error message means your clipboard data is not match either
MARKER_BLOCK_EX or MARKER_BLOCK.
Would you insert debugging code before assert to print the data in
test failure case?
    p HtmlClipboard.data_details
    assert_nothing_raised{ HtmlClipboard.data_details }


Regards,
Park Heesob


More information about the win32utils-devel mailing list