Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/test_language_bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- test_java
- test_javascript
- test_julia
- test_matlab
- test_perl
- test_php
- test_R
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions src/MATLAB/main.m
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions src/MATLAB/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: matlab
matlab: all
octave src/MATLAB/main.m build/libdice.so