diff options
author | Brad King <brad.king@kitware.com> | 2019-02-12 13:24:03 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-12 13:24:11 (GMT) |
commit | f0a57d42a2b0309c14615b7a9572f611ddda435e (patch) | |
tree | 90e1b4ac204b1e14768dd670ea5e7840913377cb /Tests | |
parent | 64ae72c52ac44984c9d5a23b19f4bd9dc9a68fdf (diff) | |
parent | 6725975bd8c47c7817a286ada9eadb9b0fbf324c (diff) | |
download | CMake-f0a57d42a2b0309c14615b7a9572f611ddda435e.zip CMake-f0a57d42a2b0309c14615b7a9572f611ddda435e.tar.gz CMake-f0a57d42a2b0309c14615b7a9572f611ddda435e.tar.bz2 |
Merge topic 'FindOctave-interp-target'
6725975bd8 FindOctave: Add target for octinterp
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2931
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindOctave/Test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/FindOctave/Test/interp_main.cpp | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Tests/FindOctave/Test/CMakeLists.txt b/Tests/FindOctave/Test/CMakeLists.txt index ce33fcd..73aa831 100644 --- a/Tests/FindOctave/Test/CMakeLists.txt +++ b/Tests/FindOctave/Test/CMakeLists.txt @@ -10,6 +10,10 @@ add_executable(test_tgt main.cpp) target_link_libraries(test_tgt Octave::Octave) add_test(NAME test_tgt COMMAND test_tgt) +add_executable(test_octinterp_tgt interp_main.cpp) +target_link_libraries(test_octinterp_tgt Octave::Octinterp) +add_test(NAME test_octinterp_tgt COMMAND test_octinterp_tgt) + add_test(NAME test_tgt_exe COMMAND Octave::Interpreter -q --eval "runtests('.')" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Tests/FindOctave/Test/interp_main.cpp b/Tests/FindOctave/Test/interp_main.cpp new file mode 100644 index 0000000..1efa187 --- /dev/null +++ b/Tests/FindOctave/Test/interp_main.cpp @@ -0,0 +1,26 @@ +#include <iostream> +#include <oct.h> +#include <octave.h> +#include <parse.h> +#include <toplev.h> + +int main(void) +{ + string_vector argv(2); + argv(0) = "embedded"; + argv(1) = "-q"; + + try { + octave_main(2, argv.c_str_vec(), 1); + octave_value_list in; + in(0) = 72.0; + const octave_value_list result = feval("sqrt", in); + std::cout << "result is " << result(0).scalar_value() << std::endl; + clean_up_and_exit(0); + } catch (const octave::exit_exception& ex) { + std::cerr << "Octave interpreter exited with status = " << ex.exit_status() + << std::endl; + } catch (const octave::execution_exception&) { + std::cerr << "error encountered in Octave evaluator!" << std::endl; + } +} |