Add test for 'natural' C++ std::string handling in C (char*).

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13482 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Leif Middelschulte 2012-08-01 12:53:17 +00:00
commit b0318dae69
3 changed files with 30 additions and 0 deletions

View file

@ -23,6 +23,7 @@ CPP_TEST_CASES += \
cpp_basic_global_var_atom \
cpp_basic_global_var_class \
cpp_basic_namespaced_class \
c_backend_cpp_natural_std_string \
c_backend_cpp_exception
#

View file

@ -0,0 +1,16 @@
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "c_backend_cpp_natural_std_string/c_backend_cpp_natural_std_string_proxy.h"
int main()
{
char *myComposedString = myStringAppend("World, ", "Hello!");
assert(myComposedString);
assert(strcmp(myComposedString, "World, Hello!") == 0);
free(myComposedString);
return 0;
}

View file

@ -0,0 +1,13 @@
%module c_backend_cpp_natural_std_string
%feature ("nspace", "1");
%include std_string.i
%inline %{
static std::string& myStringAppend(std::string &someString, const std::string &appendedString)
{
someString += appendedString;
return someString;
}
%}