Tests for Python Bytes/Unicode distinction

This commit is contained in:
Alec Cooper 2016-01-27 20:28:32 -05:00
commit 17a4143dd0
3 changed files with 121 additions and 0 deletions

View file

@ -0,0 +1,41 @@
%module python_strict_unicode
%include <std_string.i>
%include <std_wstring.i>
%begin %{
#define SWIG_PYTHON_STRICT_BYTE_CHAR
#define SWIG_PYTHON_STRICT_UNICODE_WCHAR
%}
%inline %{
std::string double_str(const std::string& in)
{
return in + in;
}
char *same_str(char* in)
{
return in;
}
std::wstring double_wstr(const std::wstring& in)
{
return in + in;
}
wchar_t *same_wstr(wchar_t* in)
{
return in;
}
std::wstring overload(const std::wstring& in)
{
return L"UNICODE";
}
std::string overload(const std::string& in)
{
return "BYTES";
}
%}