mirror of https://github.com/swig/swig
Split testcases li_std_wstring.i and li_std_wstring_inherit.i
Not many languages have support for std_wstring.i, so disable testing for these languages until added.
This commit is contained in:
parent
5131096b80
commit
a9a7b03ba6
|
@ -655,6 +655,7 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_vector_enum \
|
||||
li_std_vector_member_var\
|
||||
li_std_vector_ptr \
|
||||
li_std_wstring \
|
||||
smart_pointer_inherit \
|
||||
template_typedef_fnc \
|
||||
template_type_namespace \
|
||||
|
|
|
@ -3,74 +3,74 @@ using li_std_wstringNamespace;
|
|||
|
||||
public class runme
|
||||
{
|
||||
static private void check_equal(char a, char b)
|
||||
{
|
||||
if (a != b)
|
||||
throw new Exception("failed " + a + " " + b);
|
||||
}
|
||||
|
||||
static private void check_equal(string a, string b)
|
||||
{
|
||||
if (a != b)
|
||||
throw new Exception("failed " + a + " " + b);
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
char y='h';
|
||||
char h = 'h';
|
||||
check_equal(li_std_wstring.test_wcvalue(h), h);
|
||||
|
||||
if (li_std_wstring.test_wcvalue(y) != y)
|
||||
throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue(y));
|
||||
string x = "abc";
|
||||
check_equal(li_std_wstring.test_ccvalue(x), x);
|
||||
check_equal(li_std_wstring.test_cvalue(x), x);
|
||||
|
||||
if (li_std_wstring.test_wcvalue_w() != 'W')
|
||||
throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue_w());
|
||||
check_equal(li_std_wstring.test_wchar_overload(x), x);
|
||||
check_equal(li_std_wstring.test_wchar_overload(), null);
|
||||
|
||||
string x="hello";
|
||||
li_std_wstring.test_pointer(null);
|
||||
li_std_wstring.test_const_pointer(null);
|
||||
|
||||
if (li_std_wstring.test_ccvalue(x) != x)
|
||||
throw new Exception("bad string mapping");
|
||||
try {
|
||||
li_std_wstring.test_value(null);
|
||||
throw new Exception("NULL check failed");
|
||||
} catch (ArgumentNullException) {
|
||||
}
|
||||
|
||||
if (li_std_wstring.test_cvalue(x) != x)
|
||||
throw new Exception("bad string mapping");
|
||||
try {
|
||||
li_std_wstring.test_reference(null);
|
||||
throw new Exception("NULL check failed");
|
||||
} catch (ArgumentNullException e) {
|
||||
if (!e.Message.Contains("type is null"))
|
||||
throw new Exception("Missing text " + e);
|
||||
}
|
||||
try {
|
||||
li_std_wstring.test_const_reference(null);
|
||||
throw new Exception("NULL check failed");
|
||||
} catch (ArgumentNullException e) {
|
||||
if (!e.Message.Contains("null wstring"))
|
||||
throw new Exception("Missing text " + e);
|
||||
}
|
||||
|
||||
x = "hello";
|
||||
check_equal(li_std_wstring.test_const_reference(x), x);
|
||||
|
||||
if (li_std_wstring.test_value(x) != x)
|
||||
throw new Exception("bad string mapping: " + x + li_std_wstring.test_value(x));
|
||||
/* TODO
|
||||
string s = "abc";
|
||||
if (!li_std_wstring.test_equal_abc(s))
|
||||
throw new Exception("Not equal " + s);
|
||||
|
||||
if (li_std_wstring.test_const_reference(x) != x)
|
||||
throw new Exception("bad string mapping");
|
||||
try {
|
||||
li_std_wstring.test_throw();
|
||||
} catch (Exception e) {
|
||||
check_equal(e.Message, "throwing test_throw");
|
||||
}
|
||||
|
||||
x = "abc\0def";
|
||||
check_equal(li_std_wstring.test_value(x), x);
|
||||
check_equal(li_std_wstring.test_ccvalue(x), "abc");
|
||||
check_equal(li_std_wstring.test_wchar_overload(x), "abc");
|
||||
*/
|
||||
|
||||
string s = "he";
|
||||
s = s + "llo";
|
||||
|
||||
if (s != x)
|
||||
throw new Exception("bad string mapping: " + s + x);
|
||||
|
||||
if (li_std_wstring.test_value(s) != x)
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
if (li_std_wstring.test_const_reference(s) != x)
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
string a = s;
|
||||
|
||||
if (li_std_wstring.test_value(a) != x)
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
if (li_std_wstring.test_const_reference(a) != x)
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
string b = " world";
|
||||
|
||||
if (a + b != "hello world")
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
if (a + " world" != "hello world")
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
if ("hello" + b != "hello world")
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
s = "hello world";
|
||||
|
||||
B myB = new B("hi");
|
||||
|
||||
myB.name = "hello";
|
||||
if (myB.name != "hello")
|
||||
throw new Exception("bad string mapping");
|
||||
|
||||
myB.a = "hello";
|
||||
if (myB.a != "hello")
|
||||
throw new Exception("bad string mapping");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
%module li_std_wstring
|
||||
%include <std_basic_string.i>
|
||||
%include <std_wstring.i>
|
||||
|
||||
// The languages below are yet to provide std_wstring.i
|
||||
#if !(defined(SWIGD) || defined(SWIGGO) || defined(SWIGGUILE) || defined(SWIGJAVASCRIPT) || defined(SWIGLUA) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGPHP) || defined(SWIGR) || defined(SWIGSCILAB))
|
||||
|
||||
%include <std_wstring.i>
|
||||
|
||||
// throw is invalid in C++17 and later, only SWIG to use it
|
||||
#define TESTCASE_THROW1(T1) throw(T1)
|
||||
|
@ -10,26 +12,7 @@
|
|||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
struct A : std::wstring
|
||||
{
|
||||
A(const std::wstring& s) : std::wstring(s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
B(const std::wstring& s) : cname(0), name(s), a(s)
|
||||
{
|
||||
}
|
||||
|
||||
char *cname;
|
||||
std::wstring name;
|
||||
A a;
|
||||
|
||||
};
|
||||
|
||||
#include <string>
|
||||
|
||||
wchar_t test_wcvalue(wchar_t x) {
|
||||
return x;
|
||||
|
@ -63,33 +46,18 @@ const std::wstring& test_const_reference(const std::wstring &x) {
|
|||
void test_pointer(std::wstring *x) {
|
||||
}
|
||||
|
||||
std::wstring *test_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_const_pointer(const std::wstring *x) {
|
||||
}
|
||||
|
||||
const std::wstring *test_const_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_reference(std::wstring &x) {
|
||||
}
|
||||
|
||||
std::wstring& test_reference_out() {
|
||||
static std::wstring x = L"x";
|
||||
return x;
|
||||
}
|
||||
|
||||
bool test_equal_abc(const std::wstring &s) {
|
||||
return L"abc" == s;
|
||||
}
|
||||
|
||||
void test_throw() TESTCASE_THROW1(std::wstring){
|
||||
static std::wstring x = L"x";
|
||||
static std::wstring x = L"throwing test_throw";
|
||||
|
||||
throw x;
|
||||
}
|
||||
|
@ -102,12 +70,7 @@ size_t size_wstring(const std::wstring& s) {
|
|||
return s.size();
|
||||
}
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,12 +3,6 @@
|
|||
%include <std_wstring.i>
|
||||
|
||||
|
||||
// throw is invalid in C++17 and later, only SWIG to use it
|
||||
#define TESTCASE_THROW1(T1) throw(T1)
|
||||
%{
|
||||
#define TESTCASE_THROW1(T1)
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
struct A : std::wstring
|
||||
|
@ -30,78 +24,10 @@ struct B
|
|||
|
||||
};
|
||||
|
||||
|
||||
wchar_t test_wcvalue(wchar_t x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const wchar_t* test_ccvalue(const wchar_t* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
wchar_t* test_cvalue(wchar_t* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
wchar_t* test_wchar_overload() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
wchar_t* test_wchar_overload(wchar_t *x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
std::wstring test_value(std::wstring x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const std::wstring& test_const_reference(const std::wstring &x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
void test_pointer(std::wstring *x) {
|
||||
}
|
||||
|
||||
std::wstring *test_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_const_pointer(const std::wstring *x) {
|
||||
}
|
||||
|
||||
const std::wstring *test_const_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_reference(std::wstring &x) {
|
||||
}
|
||||
|
||||
std::wstring& test_reference_out() {
|
||||
static std::wstring x = L"x";
|
||||
return x;
|
||||
}
|
||||
|
||||
bool test_equal_abc(const std::wstring &s) {
|
||||
return L"abc" == s;
|
||||
}
|
||||
|
||||
void test_throw() TESTCASE_THROW1(std::wstring){
|
||||
static std::wstring x = L"x";
|
||||
|
||||
throw x;
|
||||
}
|
||||
|
||||
const char * non_utf8_c_str() {
|
||||
return "h\xe9llo";
|
||||
}
|
||||
|
||||
size_t size_wstring_size(const std::wstring& s) {
|
||||
return s.size();
|
||||
}
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
# do not dump Octave core
|
||||
if exist("crash_dumps_octave_core", "builtin")
|
||||
crash_dumps_octave_core(0);
|
||||
endif
|
||||
|
||||
li_std_wstring
|
||||
|
||||
x="h";
|
||||
|
||||
if (li_std_wstring.test_wcvalue(x) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
x="hello";
|
||||
if (li_std_wstring.test_ccvalue(x) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (li_std_wstring.test_cvalue(x) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (li_std_wstring.test_value(x) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (li_std_wstring.test_const_reference(x) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
|
||||
s = li_std_wstring.wstring("he");
|
||||
s = s + "llo";
|
||||
|
||||
if (s != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (s(1:4) != x(1:4))
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (li_std_wstring.test_value(s) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (li_std_wstring.test_const_reference(s) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
a = li_std_wstring.A(s);
|
||||
|
||||
if (li_std_wstring.test_value(a) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (li_std_wstring.test_const_reference(a) != x)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
b = li_std_wstring.wstring(" world");
|
||||
|
||||
if (a + b != "hello world")
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if (a + " world" != "hello world")
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
if ("hello" + b != "hello world")
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
c = "hello" + b;
|
||||
if (c.find_last_of("l") != 9)
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
s = "hello world";
|
||||
|
||||
b = li_std_wstring.B("hi");
|
||||
|
||||
b.name = li_std_wstring.wstring("hello");
|
||||
if (b.name != "hello")
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
|
||||
b.a = li_std_wstring.A("hello");
|
||||
if (b.a != "hello")
|
||||
error("bad string mapping")
|
||||
endif
|
||||
|
||||
|
|
@ -1,32 +1,7 @@
|
|||
import li_std_wstring_inherit
|
||||
import sys
|
||||
|
||||
x = u"h"
|
||||
|
||||
if li_std_wstring_inherit.test_wcvalue(x) != x:
|
||||
print li_std_wstring_inherit.test_wcvalue(x)
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
x = u"hello"
|
||||
if li_std_wstring_inherit.test_ccvalue(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_cvalue(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_wchar_overload(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_wchar_overload("not unicode") != "not unicode":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_value(x) != x:
|
||||
print x, li_std_wstring_inherit.test_value(x)
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_const_reference(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
|
||||
s = li_std_wstring_inherit.wstring(u"he")
|
||||
s = s + u"llo"
|
||||
|
@ -38,20 +13,7 @@ if s != x:
|
|||
if s[1:4] != x[1:4]:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_value(s) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_const_reference(s) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
a = li_std_wstring_inherit.A(s)
|
||||
|
||||
if li_std_wstring_inherit.test_value(a) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring_inherit.test_const_reference(a) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
b = li_std_wstring_inherit.wstring(" world")
|
||||
|
||||
if a + b != "hello world":
|
||||
|
@ -70,8 +32,6 @@ if not li_std_wstring_inherit.is_python_builtin():
|
|||
if c.find_last_of("l") != 9:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
s = "hello world"
|
||||
|
||||
b = li_std_wstring_inherit.B("hi")
|
||||
|
||||
b.name = li_std_wstring_inherit.wstring(u"hello")
|
||||
|
@ -83,24 +43,3 @@ b.a = li_std_wstring_inherit.A("hello")
|
|||
if b.a != u"hello":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
# Byte strings only converted in Python 2
|
||||
if sys.version_info[0:2] < (3, 0):
|
||||
x = b"hello there"
|
||||
if li_std_wstring_inherit.test_value(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
# Invalid utf-8 in a byte string fails in all versions
|
||||
x = b"h\xe9llo"
|
||||
try:
|
||||
li_std_wstring_inherit.test_value(x)
|
||||
raise RuntimeError("TypeError not thrown")
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# Check surrogateescape
|
||||
if sys.version_info[0:2] > (3, 1):
|
||||
x = u"h\udce9llo" # surrogate escaped representation of C char*: "h\xe9llo"
|
||||
if li_std_wstring_inherit.non_utf8_c_str() != x:
|
||||
raise RuntimeError("surrogateescape not working")
|
||||
if li_std_wstring_inherit.size_wstring(x) != 5 and len(x) != 5:
|
||||
raise RuntimeError("Unexpected length")
|
||||
|
|
|
@ -1,87 +1,60 @@
|
|||
import li_std_wstring
|
||||
import sys
|
||||
|
||||
x = u"h"
|
||||
def check_equal(a, b):
|
||||
if a != b:
|
||||
raise RuntimeError("failed {} {}".format(a, b))
|
||||
|
||||
if li_std_wstring.test_wcvalue(x) != x:
|
||||
print li_std_wstring.test_wcvalue(x)
|
||||
raise RuntimeError("bad string mapping")
|
||||
h = u"h"
|
||||
check_equal(li_std_wstring.test_wcvalue(h), h)
|
||||
|
||||
x = u"hello"
|
||||
if li_std_wstring.test_ccvalue(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
x = u"abc"
|
||||
check_equal(li_std_wstring.test_ccvalue(x), x)
|
||||
check_equal(li_std_wstring.test_cvalue(x), x)
|
||||
|
||||
if li_std_wstring.test_cvalue(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
check_equal(li_std_wstring.test_wchar_overload(x), x)
|
||||
check_equal(li_std_wstring.test_wchar_overload(), None)
|
||||
|
||||
if li_std_wstring.test_wchar_overload(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
li_std_wstring.test_pointer(None)
|
||||
li_std_wstring.test_const_pointer(None)
|
||||
|
||||
if li_std_wstring.test_wchar_overload("not unicode") != "not unicode":
|
||||
raise RuntimeError("bad string mapping")
|
||||
try:
|
||||
li_std_wstring.test_value(None)
|
||||
raise RuntimeError("NULL check failed")
|
||||
except TypeError as e:
|
||||
pass
|
||||
|
||||
if li_std_wstring.test_value(x) != x:
|
||||
print x, li_std_wstring.test_value(x)
|
||||
raise RuntimeError("bad string mapping")
|
||||
try:
|
||||
li_std_wstring.test_reference(None)
|
||||
raise RuntimeError("NULL check failed")
|
||||
except ValueError as e:
|
||||
if "invalid null reference" not in str(e):
|
||||
raise RuntimeError("Missing text {}".format(e))
|
||||
try:
|
||||
li_std_wstring.test_const_reference(None)
|
||||
raise RuntimeError("NULL check failed")
|
||||
except ValueError as e:
|
||||
if "invalid null reference" not in str(e):
|
||||
raise RuntimeError("Missing text {}".format(e))
|
||||
|
||||
if li_std_wstring.test_const_reference(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
x = "hello"
|
||||
check_equal(li_std_wstring.test_const_reference(x), x)
|
||||
|
||||
s = "abc"
|
||||
if not li_std_wstring.test_equal_abc(s):
|
||||
raise RuntimeError("Not equal {}".format(s))
|
||||
|
||||
s = li_std_wstring.wstring(u"he")
|
||||
s = s + u"llo"
|
||||
try:
|
||||
li_std_wstring.test_throw
|
||||
except RuntimeError as e:
|
||||
check_equal(e.message, "throwing test_throw")
|
||||
|
||||
if s != x:
|
||||
print s, x
|
||||
raise RuntimeError("bad string mapping")
|
||||
x = "abc\0def"
|
||||
check_equal(li_std_wstring.test_value(x), x)
|
||||
check_equal(li_std_wstring.test_ccvalue(x), "abc")
|
||||
check_equal(li_std_wstring.test_wchar_overload(x), "abc")
|
||||
|
||||
if s[1:4] != x[1:4]:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_value(s) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_const_reference(s) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
a = li_std_wstring.A(s)
|
||||
|
||||
if li_std_wstring.test_value(a) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_const_reference(a) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
b = li_std_wstring.wstring(" world")
|
||||
|
||||
if a + b != "hello world":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if a + " world" != "hello world":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
# This is expected to fail if -builtin is used
|
||||
# Reverse operators not supported in builtin types
|
||||
if not li_std_wstring.is_python_builtin():
|
||||
if "hello" + b != "hello world":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
c = "hello" + b
|
||||
if c.find_last_of("l") != 9:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
s = "hello world"
|
||||
|
||||
b = li_std_wstring.B("hi")
|
||||
|
||||
b.name = li_std_wstring.wstring(u"hello")
|
||||
if b.name != "hello":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
|
||||
b.a = li_std_wstring.A("hello")
|
||||
if b.a != u"hello":
|
||||
raise RuntimeError("bad string mapping")
|
||||
################### Python specific
|
||||
|
||||
# Byte strings only converted in Python 2
|
||||
if sys.version_info[0:2] < (3, 0):
|
||||
|
|
|
@ -1,42 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
require 'swig_assert'
|
||||
require 'li_std_wstring_inherit'
|
||||
|
||||
x = "abc"
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_ccvalue(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_value(Li_std_wstring_inherit::Wstring.new(x))", "x", binding)
|
||||
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload()", "nil", binding)
|
||||
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_const_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_const_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_reference(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding)
|
||||
|
||||
x = "y"
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding)
|
||||
a = Li_std_wstring_inherit::A.new(x)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_value(a)", "x", binding)
|
||||
|
||||
x = "hello"
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_const_reference(x)", "x", binding)
|
||||
|
||||
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_pointer_out", "'x'", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_const_pointer_out", "'x'", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_reference_out()", "'x'", binding)
|
||||
|
||||
s = "abc"
|
||||
swig_assert("Li_std_wstring_inherit.test_equal_abc(s)", binding)
|
||||
|
||||
begin
|
||||
Li_std_wstring_inherit.test_throw
|
||||
rescue RuntimeError => e
|
||||
swig_assert_equal("e.message", "'x'", binding)
|
||||
end
|
||||
|
||||
x = "abc\0def"
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_ccvalue(x)", '"abc"', binding)
|
||||
swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload(x)", '"abc"', binding)
|
||||
|
|
|
@ -2,38 +2,48 @@
|
|||
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)
|
||||
h = "h"
|
||||
swig_assert_equal("Li_std_wstring.test_wcvalue(h)", "h", binding)
|
||||
|
||||
x = "abc"
|
||||
swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_cvalue(x)", "x", binding)
|
||||
|
||||
swig_assert_equal("Li_std_wstring.test_wchar_overload(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)
|
||||
Li_std_wstring.test_pointer(nil)
|
||||
Li_std_wstring.test_const_pointer(nil)
|
||||
|
||||
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)
|
||||
begin
|
||||
Li_std_wstring.test_value(nil)
|
||||
raise RuntimeError, "NULL check failed"
|
||||
rescue TypeError => e
|
||||
end
|
||||
|
||||
begin
|
||||
Li_std_wstring.test_reference(nil)
|
||||
raise RuntimeError, "NULL check failed"
|
||||
rescue ArgumentError => e
|
||||
swig_assert_simple(e.message.include? "invalid null reference")
|
||||
end
|
||||
begin
|
||||
Li_std_wstring.test_const_reference(nil)
|
||||
raise RuntimeError, "NULL check failed"
|
||||
rescue ArgumentError => e
|
||||
swig_assert_simple(e.message.include? "invalid null reference")
|
||||
end
|
||||
|
||||
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)
|
||||
swig_assert_equal("e.message", "'throwing test_throw'", binding)
|
||||
end
|
||||
|
||||
x = "abc\0def"
|
||||
|
|
Loading…
Reference in New Issue