swig/Examples/test-suite/octave/catches_strings_runme.m
William S Fulton ed333b6b97 std::string throws typemaps
Go, Guile, Racket, Scilab: Add throws typemaps for std::string so that
thrown string exception messages can be seen.

Test all language for std::string throws typemaps
2022-09-19 09:09:29 +01:00

32 lines
734 B
Mathematica

# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
catches_strings
exception_thrown = false;
try
StringsThrower.charstring();
catch e
if (isempty(strfind(e.message, "charstring message")))
error("incorrect exception message: %s", e.message)
endif
exception_thrown = true;
end_try_catch
if (!exception_thrown)
error("Should have thrown an exception");
endif
exception_thrown = false;
try
StringsThrower.stdstring();
catch e
if (isempty(strfind(e.message, "stdstring message")))
error("incorrect exception message: %s", e.message)
endif
exception_thrown = true;
end_try_catch
if (!exception_thrown)
error("Should have thrown an exception");
endif