Merge branch 'tamuratak-fix_ruby_wstring'
* tamuratak-fix_ruby_wstring:
[ruby] use %fragment to clarify the dependency of code.
[ruby] should initialize static variables inside %init{}, in which it will not be excuted concurrently by multiple threads.
[ruby] * use static variable to avoid creating stirngs every time. * fix possible overflow.
[ruby] add std::wstring tests for string including a null terminator.
[ruby] * rewrite SWIG_AsWCharPtrAndSize and SWIG_FromWCharPtrAndSize * use UTF-32LE and UTF-16LE to avoid BOM * add tests
[ruby] use WCHAR_MAX to determine the encoding of std::wstring.
[ruby] add a few tests for std::wstring
[ruby] fix support for std::wstring.
This commit is contained in:
commit
e9e9531dc3
6 changed files with 137 additions and 53 deletions
|
|
@ -78,6 +78,10 @@ std::wstring& test_reference_out() {
|
|||
return x;
|
||||
}
|
||||
|
||||
bool test_equal_abc(const std::wstring &s) {
|
||||
return L"abc" == s;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ CPP_TEST_CASES = \
|
|||
li_std_queue \
|
||||
li_std_set \
|
||||
li_std_stack \
|
||||
li_std_wstring \
|
||||
primitive_types \
|
||||
ruby_keywords \
|
||||
ruby_minherit_shared_ptr \
|
||||
|
|
|
|||
42
Examples/test-suite/ruby/li_std_wstring_runme.rb
Normal file
42
Examples/test-suite/ruby/li_std_wstring_runme.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
require 'swig_assert'
|
||||
require 'li_std_wstring'
|
||||
|
||||
x = "abc"
|
||||
swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_value(Li_std_wstring::Wstring.new(x))", "x", binding)
|
||||
|
||||
swig_assert_equal("Li_std_wstring.test_wchar_overload()", "nil", binding)
|
||||
|
||||
swig_assert_equal("Li_std_wstring.test_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_reference(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
|
||||
x = "y"
|
||||
swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding)
|
||||
a = Li_std_wstring::A.new(x)
|
||||
swig_assert_equal("Li_std_wstring.test_value(a)", "x", binding)
|
||||
|
||||
x = "hello"
|
||||
swig_assert_equal("Li_std_wstring.test_const_reference(x)", "x", binding)
|
||||
|
||||
|
||||
swig_assert_equal("Li_std_wstring.test_pointer_out", "'x'", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_const_pointer_out", "'x'", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_reference_out()", "'x'", binding)
|
||||
|
||||
s = "abc"
|
||||
swig_assert("Li_std_wstring.test_equal_abc(s)", binding)
|
||||
|
||||
begin
|
||||
Li_std_wstring.test_throw
|
||||
rescue RuntimeError => e
|
||||
swig_assert_equal("e.message", "'x'", binding)
|
||||
end
|
||||
|
||||
x = "abc\0def"
|
||||
swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_ccvalue(x)", '"abc"', binding)
|
||||
swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", '"abc"', binding)
|
||||
Loading…
Add table
Add a link
Reference in a new issue