swig/Examples/test-suite/c/li_std_string_runme.cxx
Vadim Zeitlin fd11a591a3 Add cxx{in,out}type typemaps and use them for std::string
This makes using returning strings much simpler to use from C++ code as
the returned pointers don't have to be deleted manually -- although, of
course, this does require an extra allocation and copy and so should be
avoided for the very long strings.

Add a new runtime test showing how simple and convenient it is to use
the functions working with string using the C++ wrappers now.
2021-12-07 20:54:28 +01:00

26 lines
731 B
C++

#include "li_std_string_wrap.h"
#include <assert.h>
using namespace li_std_string;
int main(int argc, const char *argv[]) {
Structure st;
assert( st.MemberString().empty() );
st.MemberString("bloordyblop");
assert( st.MemberString() == "bloordyblop" );
assert( st.MemberString2() == "member string 2" );
assert( st.ConstMemberString() == "const member string" );
st.StaticMemberString(std::string("static bloordyblop"));
assert( st.StaticMemberString() == "static bloordyblop" );
assert( Structure::StaticMemberString2() == "static member string 2" );
assert( Structure::ConstStaticMemberString() == "const static member string" );
Foo f;
assert( f.test("1+") == "1+1" );
}