Skip to content

Commit 9c18de2

Browse files
committed
add template for unit test
1 parent ec73e90 commit 9c18de2

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

src/templates/miss_hit.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# style guide (https://florianschanda.github.io/miss_hit/style_checker.html)
2+
line_length: 100
3+
regex_function_name: "((test_[a-z]+)|[a-z]+)(([A-Z]){1}[A-Za-z]+)*"
4+
5+
# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
6+
metric "cnest": limit 4
7+
metric "file_length": limit 500
8+
metric "cyc": limit 15
9+
metric "parameters": limit 5

src/templates/templateFunction.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717
% :param argin3: (dimension) optional argument
1818
% :type argin3: integer
1919
%
20-
% :returns: - :argout1: (type) (dimension)
21-
% - :argout2: (type) (dimension)
20+
% :returns:
21+
% :argout1: (type) (dimension)
22+
% :argout2: (type) (dimension)
23+
%
24+
% :output:
25+
% :file created: description
26+
% :other file created: description
2227
%
2328
% .. todo:
2429
%

src/templates/templateTest.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
% (C) Copyright 2020 CPP_BIDS developers
2+
3+
function test_suite = test_templateTest %#ok<*STOUT>
4+
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
5+
test_functions = localfunctions(); %#ok<*NASGU>
6+
catch % no problem; early Matlab versions can use initTestSuite fine
7+
end
8+
initTestSuite;
9+
end
10+
11+
function test_templateTestBasic()
12+
13+
%% set up
14+
15+
% cfg.input_1 = ...
16+
17+
%% use function to test
18+
19+
% actualOupout = foo(cfg);
20+
21+
%% assert that output content / type / size is what you expect
22+
23+
% expectedOuput = X;
24+
25+
% assertEqual(actualOupout, expectedOuput)
26+
27+
%% clean up (delete temporary files that were created)
28+
29+
end

0 commit comments

Comments
 (0)