Skip to content

Commit

Permalink
Added unit tests for octave-api
Browse files Browse the repository at this point in the history
  • Loading branch information
oheim committed Nov 13, 2015
1 parent 3809000 commit 3afa02b
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:
# 32 bit compatibility (since CMake is a 32 bit bin)
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -qq libc6:i386; fi
# Install Octave for test of client API
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -qq octave liboctave-dev; fi
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -qq octave liboctave-dev libmpfr-dev; fi
# Install CMake bin (32 bit)
- if [ $TRAVIS_OS_NAME == linux ]; then wget --no-check-certificate -P /tmp http://www.cmake.org/files/v2.8/cmake-2.8.12.1-Linux-i386.sh; fi
- if [ $TRAVIS_OS_NAME == linux ]; then chmod +rx /tmp/cmake-2.8.12.1-Linux-i386.sh; fi
Expand All @@ -29,7 +29,7 @@ before_script:
script:
- make -C viewer/build
- make -C client-api/Octave
- if [ $TRAVIS_OS_NAME == linux ]; then make -C client-api/Octave install; fi
- if [ $TRAVIS_OS_NAME == linux ]; then make -C client-api/Octave check; fi

after_success:
- if [ $TRAVIS_OS_NAME == linux ]; then make -C client-api/Octave html; fi
Expand Down
2 changes: 1 addition & 1 deletion client-api/Octave/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vibes-*.tar.gz
vibes-bundle/**
vibes-html/**
fntest.log
fntests.log
octave-*

27 changes: 25 additions & 2 deletions client-api/Octave/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,39 @@ md5: $(RELEASE_TARBALL) $(HTML_TARBALL)
##
## Testing Process
##
## Interactive shell with the package installed and loaded
## Interactive shell with the package installed and loaded /
## Non-interactive processing of integrated unit tests
##

.PHONY: run
.PHONY: run check
PUBLIC_FUNCTIONS = $(patsubst inst/%.m,%,$(wildcard inst/+vibes/*.m))

run: $(INSTALLED_PACKAGE)
@echo "Run GNU Octave with the development version of the package"
@$(OCTAVE) --no-gui --silent --eval "pkg load $(PACKAGE)" --persist
@echo

check: $(INSTALLED_PACKAGE)
@echo "Testing package in GNU Octave ..."
@# Make sure that the interval package is present, some tests depend on this
@$(OCTAVE) --no-gui --silent \
--eval "try;" \
--eval "temp = pkg ('describe', 'interval');" \
--eval "catch;" \
--eval "pkg ('install', '-forge', 'interval');" \
--eval "end_try_catch;"
@rm -f ~/.vibes.json
@$(OCTAVE) --no-gui --silent \
--eval "pkg load $(PACKAGE);" \
--eval "success = true;" \
--eval "targets = strsplit ('$(PUBLIC_FUNCTIONS)', ' ');" \
--eval "for target = targets;" \
--eval "[n, nmax] = test (target{1}, 'verbose');" \
--eval "success &= (n == nmax);" \
--eval "endfor;" \
--eval "exit (not (success));"
@cat ~/.vibes.json

##
## Cleanup
##
Expand Down
5 changes: 5 additions & 0 deletions client-api/Octave/inst/+vibes/axisAuto.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ function axisAuto ()
__vibes__ ('axisAuto');

endfunction

%!test
%! vibes.beginDrawing
%! vibes.axisAuto
%! vibes.endDrawing
8 changes: 8 additions & 0 deletions client-api/Octave/inst/+vibes/axisLabels.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ function axisLabels (varargin)
__vibes__ ('axisLabels', varargin{:});

endfunction

%!shared
%! vibes.beginDrawing
%!test vibes.axisLabels ('x', 'y', 'z')
%!test vibes.axisLabels ({'x', 'y', 'z'})
%!test vibes.axisLabels ({'a', 'b', 'c'}, 'alphabet')
%!shared
%! vibes.endDrawing
10 changes: 10 additions & 0 deletions client-api/Octave/inst/+vibes/beginDrawing.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,13 @@ function beginDrawing (filename)
endswitch

endfunction

%!test
%! vibes.beginDrawing
%! vibes.endDrawing
%!warning vibes.beginDrawing; vibes.beginDrawing; vibes.endDrawing
%!test
%! vibes.beginDrawing ('.vibes-custom.json')
%! assert (exist ('.vibes-custom.json', 'file'))
%! vibes.endDrawing
%! delete ('.vibes-custom.json')
50 changes: 50 additions & 0 deletions client-api/Octave/inst/+vibes/drawBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,53 @@ function drawBox (varargin)
__vibes__ ('drawBox', varargin{:});

endfunction

%!shared x,y,z
%! vibes.beginDrawing
%! x = [ 0 2 ; ...
%! 7 22 ];
%! y = [ 1 2 3 4 ; ...
%! 2 3 4 5 ];
%! z = [ 1 2 ; ...
%! 3 4 ; ...
%! 5 6 ; ...
%! 7 8 ];
%!test vibes.drawBox (x)
%!test vibes.drawBox (y)
%!test vibes.drawBox (z)
%!test vibes.drawBox (-1, 0, 1, 2)
%!test vibes.drawBox (-1, 0, 1, 2, 4, 5)
%!shared
%! vibes.endDrawing

%!shared ix,iy,iz,dx,dy,dz,rx,ry,rz
%! pkg load interval
%! vibes.beginDrawing
%! x = [ 0 2 ; ...
%! 7 22 ];
%! y = [ 1 2 3 4 ; ...
%! 2 3 4 5 ];
%! z = [ 1 2 ; ...
%! 3 4 ; ...
%! 5 6 ; ...
%! 7 8 ];
%! ix = infsup (x)
%! iy = infsup (y)
%! iz = infsup (z)
%! dx = infsupdec (x)
%! dy = infsupdec (y)
%! dz = infsupdec (z)
%! rx = infsup (x, x + 100)
%! ry = infsup (y, y + 100)
%! rz = infsup (z, z + 100)
%!test vibes.drawBox (ix)
%!test vibes.drawBox (iy)
%!test vibes.drawBox (iz)
%!test vibes.drawBox (dx)
%!test vibes.drawBox (dy)
%!test vibes.drawBox (dz)
%!test vibes.drawBox (rx)
%!test vibes.drawBox (ry)
%!test vibes.drawBox (rz)
%!shared
%! vibes.endDrawing
13 changes: 13 additions & 0 deletions client-api/Octave/inst/+vibes/drawLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,16 @@ function drawLine (varargin)
__vibes__ ('drawLine', varargin{:});

endfunction

%!shared x
%! vibes.beginDrawing
%! x = [ 0 0 ; ...
%! 1 1 ; ...
%! 2 2 ];
%!test vibes.drawLine (x)
%!test vibes.drawLine (x, 'figure', 'foo')
%!test vibes.drawLine (x, 'red')
%!test vibes.drawLine (x, 'figure', 'bar', 'blue')
%!test vibes.drawLine (x, 'green', 'figure', 'baz')
%!shared
%! vibes.endDrawing
5 changes: 5 additions & 0 deletions client-api/Octave/inst/+vibes/endDrawing.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ function endDrawing ()
__vibes__ ('endDrawing');

endfunction

%!test
%! vibes.beginDrawing
%! vibes.endDrawing
%!warning vibes.endDrawing
8 changes: 8 additions & 0 deletions client-api/Octave/inst/+vibes/newFigure.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ function newFigure (name)
endswitch

endfunction

%!shared
%! vibes.beginDrawing
%!test vibes.newFigure
%!test vibes.newFigure ('Foobar')
%!test vibes.newFigure
%!shared
%! vibes.endDrawing

0 comments on commit 3afa02b

Please sign in to comment.