scilab: implement test li_std_string
This commit is contained in:
parent
35ef7b774b
commit
139449f424
3 changed files with 72 additions and 3 deletions
|
|
@ -83,11 +83,22 @@ void test_const_pointer_throw() throw(const std::string *) {
|
|||
std::string *Structure::StaticMemberString2 };
|
||||
*/
|
||||
|
||||
|
||||
%inline %{
|
||||
std::string GlobalString;
|
||||
std::string GlobalString2 = "global string 2";
|
||||
const std::string ConstGlobalString = "const global string";
|
||||
|
||||
#ifdef SWIGSCILAB
|
||||
%rename(St) MemberString;
|
||||
%rename(Str) MemberString;
|
||||
%rename(Str2) MemberString2;
|
||||
%rename(StaticStr) StaticMemberString;
|
||||
%rename(StaticStr2) StaticMemberString2;
|
||||
%rename(ConstStr) ConstMemberString;
|
||||
%rename(ConstStaticStr) ConstStaticMemberString;
|
||||
#endif
|
||||
|
||||
struct Structure {
|
||||
std::string MemberString;
|
||||
std::string MemberString2;
|
||||
|
|
|
|||
58
Examples/test-suite/scilab/li_std_string_extra_runme.sci
Normal file
58
Examples/test-suite/scilab/li_std_string_extra_runme.sci
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
exec("swigtest.start", -1);
|
||||
|
||||
x = "hello";
|
||||
|
||||
// li_std_string tests
|
||||
|
||||
// Function tests
|
||||
|
||||
if test_ccvalue(x) <> x then swigtesterror(); end
|
||||
if test_cvalue(x) <> x then swigtesterror(); end
|
||||
if test_value(x) <> x then swigtesterror(); end
|
||||
|
||||
if test_const_reference(x) <> x then swigtesterror(); end
|
||||
if test_reference_input(x) <> x then swigtesterror(); end
|
||||
if test_reference_inout(x) <> x+x then swigtesterror(); end
|
||||
|
||||
//if test_reference_out() <> "test_reference_out message" then swigtesterror(); end
|
||||
//if test_const_pointer_out() <> "x" then swigtesterror(); end
|
||||
|
||||
s = "initial string";
|
||||
|
||||
// Global variable tests
|
||||
|
||||
if GlobalString2_get() <> "global string 2" then swigtesterror(); end
|
||||
GlobalString2_set(s);
|
||||
if GlobalString2_get() <> s then swigtesterror(); end
|
||||
|
||||
if ConstGlobalString_get() <> "const global string" then swigtesterror(); end
|
||||
|
||||
// Member variable tests
|
||||
|
||||
myStructure = new_Structure();
|
||||
if Structure_Str2_get(myStructure) <> "member string 2" then swigtesterror(); end
|
||||
|
||||
Structure_Str2_set(myStructure, s);
|
||||
if Structure_Str2_get(myStructure) <> s then swigtesterror(); end
|
||||
|
||||
if Structure_ConstStr_get(myStructure) <> "const member string" then swigtesterror(); end
|
||||
|
||||
if Structure_StaticStr2_get() <> "static member string 2" then swigtesterror(); end
|
||||
|
||||
Structure_StaticStr2_set(s);
|
||||
if Structure_StaticStr2_get() <> s then swigtesterror(); end
|
||||
|
||||
if Structure_ConstStaticStr_get() <> "const static member string" then swigtesterror(); end
|
||||
|
||||
|
||||
if stdstring_empty() <> "" then swigtesterror(); end
|
||||
if c_empty() <> "" then swigtesterror(); end
|
||||
|
||||
|
||||
// li_std_string_extra tests
|
||||
|
||||
//if test_value_basic1(x) <> x then swigtesterror(); end
|
||||
//if test_value_basic2(x) <> x then swigtesterror(); end
|
||||
//if test_value_basic3(x) <> x then swigtesterror(); end
|
||||
|
||||
exec("swigtest.quit", -1);
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
/*
|
||||
* CHAR
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(char), "header", fragment="SWIG_SciString_AsChar") {
|
||||
#define SWIG_AsVal_char(scilabValue, valuePointer) SWIG_SciString_AsChar(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
|
|
@ -76,8 +77,6 @@ SWIG_SciString_FromChar(void *_pvApiCtx, int _iVarOut, char _chValue) {
|
|||
* CHAR *
|
||||
*/
|
||||
|
||||
|
||||
|
||||
%fragment("SWIG_AsCharArray", "header", fragment = "SWIG_SciString_AsCharPtr") {
|
||||
#define SWIG_AsCharArray(scilabValue, charPtrPointer, charPtrLength) SWIG_SciString_AsCharPtr(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, fname)
|
||||
}
|
||||
|
|
@ -143,7 +142,7 @@ SWIG_SciString_AsCharPtrAndSize(void *_pvApiCtx, int _iVar, char **_pcValue, siz
|
|||
}
|
||||
|
||||
if (_piLength != NULL) {
|
||||
*_piLength = strlen(*_pcValue);
|
||||
*_piLength = strlen(*_pcValue) + 1;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -177,6 +176,7 @@ SWIG_SciString_FromCharPtr(void *_pvApiCtx, int _iVarOut, const char *_pchValue)
|
|||
/*
|
||||
* CHAR * ARRAY
|
||||
*/
|
||||
|
||||
%fragment("SWIG_SciString_AsCharPtrArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_AsCharPtrArrayAndSize(void *_pvApiCtx, int _iVar, char ***_charPtrArray, int* _charPtrArraySize, char *_fname) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue