diff --git a/.github/workflows/test_language_bindings.yml b/.github/workflows/test_language_bindings.yml index bffbb1c2a..010b0caab 100644 --- a/.github/workflows/test_language_bindings.yml +++ b/.github/workflows/test_language_bindings.yml @@ -21,6 +21,7 @@ jobs: - test_java - test_javascript - test_julia + - test_matlab - test_perl - test_php - test_R @@ -160,6 +161,17 @@ jobs: run: | PATH="$PATH:$PWD/julia-1.8.2/bin" make julia + test_matlab: + name: "Test: Matlab/Octave" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: prereqs + run: sudo apt-get install octave -y + - name: run + run: make matlab + + test_perl: name: "Test: Perl" runs-on: ubuntu-20.04 diff --git a/src/MATLAB/main.m b/src/MATLAB/main.m new file mode 100644 index 000000000..09ac11175 --- /dev/null +++ b/src/MATLAB/main.m @@ -0,0 +1,28 @@ +% Load the shared library +libraryPath = '../../build/libdice.so'; % Replace with the actual path to your library +lib = dlopen(libraryPath, 1); + +% Define the function signature +returnType = 'void'; +argTypes = {'char*', 'char*'}; +roll_and_write = libpointer('string', ''); + +% Call the function +[param1, param2] = deal('20d8', 'output.txt'); +calllib(lib, 'roll_and_write', roll_and_write, param1, param2); + +% Unload the library +dlclose(lib); + +% read result +outputFilePath = 'output.txt'; % Replace with the actual path to your output file +result = dlmread(outputFilePath); + +% Check if the result is greater than 1 +if result > 1 + disp('Result is greater than 1!'); + exit(0) +else + disp('Result is not greater than 1.'); +end +exit(1) diff --git a/src/MATLAB/target.mk b/src/MATLAB/target.mk new file mode 100644 index 000000000..430785fb8 --- /dev/null +++ b/src/MATLAB/target.mk @@ -0,0 +1,3 @@ +.PHONY: matlab +matlab: all + octave src/MATLAB/main.m build/libdice.so