Skip to content

Commit fa73e0b

Browse files
committed
tests: add cc files for testing oct files
Fixes Issue #181.
1 parent 7ad4cbf commit fa73e0b

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

test/octfiles/test_all.m

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
%% -*- texinfo -*-
2+
%% @defun test_all ()
3+
%% tests
4+
%%
5+
%% @example
6+
%% 42
7+
%% @result{} ans = 42
8+
%% @end example
9+
%%
10+
%% Note its not possible to call doctest from a doctest [1].
11+
%% Instead, we use octave BIST mechanism.
12+
%%
13+
%% [1] https://github.com/catch22/octave-doctest/issues/184
14+
%%
15+
%% @end defun
16+
17+
function test_all()
18+
19+
end
20+
21+
%!test
22+
%! [numpass, numtests, ~] = doctest ('test_octfile_single_fcn');
23+
%! assert (numtests, 2)
24+
%! assert (numpass, 2)
25+
26+
%!test
27+
%! % different behaviour with or without extension
28+
%! [dir, ~, ~] = fileparts (which ('test_octfile_multi.oct'));
29+
%! autoload ('test_subfcn1', fullfile (dir, 'test_octfile_multi.oct'));
30+
%! [numpass, numtests, ~] = doctest ('test_octfile_multi');
31+
%! assert (numtests, 1)
32+
%! assert (numpass, 1)
33+
%! [numpass, numtests, ~] = doctest ('test_octfile_multi.oct');
34+
%! assert (numtests, 4)
35+
%! assert (numpass, 4)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <octave/oct.h>
2+
3+
DEFUN_DLD (test_octfile_multi, args, ,
4+
"-*- texinfo -*-\n\
5+
@deftypefn {} {} test_octfile_multi ()\n\
6+
Testing\n\
7+
\n\
8+
@example\n\
9+
a = 42\n\
10+
@result{} a = 42\n\
11+
@end example\n\
12+
@end deftypefn")
13+
{
14+
return ovl (0);
15+
}
16+
17+
DEFUN_DLD (test_subfcn1, args, ,
18+
"-*- texinfo -*-\n\
19+
@deftypefn {} {} test_subfcn1 ()\n\
20+
Testing\n\
21+
\n\
22+
@example\n\
23+
a = 43\n\
24+
@result{} a = 43\n\
25+
@end example\n\
26+
@end deftypefn")
27+
{
28+
return ovl (0);
29+
}
30+
31+
DEFUN_DLD (test_subfcn2, args, ,
32+
"-*- texinfo -*-\n\
33+
@deftypefn {} {} test_subfcn2 ()\n\
34+
Testing\n\
35+
\n\
36+
@example\n\
37+
a = 44\n\
38+
@result{} a = 44\n\
39+
a = a + 1\n\
40+
@result{} a = 45\n\
41+
@end example\n\
42+
@end deftypefn")
43+
{
44+
return ovl (0);
45+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <octave/oct.h>
2+
3+
DEFUN_DLD (test_octfile_single_fcn, args, ,
4+
"-*- texinfo -*-\n\
5+
@deftypefn {} {} test_octfile_single_fcn ()\n\
6+
Testing\n\
7+
\n\
8+
@example\n\
9+
b = 42\n\
10+
@result{} b = 42\n\
11+
b = b + 1\n\
12+
@result{} b = 43\n\
13+
@end example\n\
14+
@end deftypefn")
15+
{
16+
return ovl (0);
17+
}

0 commit comments

Comments
 (0)