Skip to content

Commit 8960007

Browse files
committed
add lint test
1 parent b4a0808 commit 8960007

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

+matmap3d/MLint.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

+matmap3d/TestALint.m

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
classdef TestALint < matlab.unittest.TestCase
2+
3+
properties
4+
TestData
5+
end
6+
7+
properties (TestParameter)
8+
file = get_files()
9+
end
10+
11+
methods (TestClassSetup)
12+
13+
function get_files(tc)
14+
import matlab.unittest.constraints.IsFile
15+
import matlab.unittest.constraints.IsFolder
16+
17+
cwd = fileparts(mfilename('fullpath'));
18+
cfg_file = fullfile(cwd, "MLint.txt");
19+
20+
tc.assumeThat(cfg_file, IsFile)
21+
22+
tc.TestData.cfg_file = cfg_file;
23+
24+
end
25+
26+
end
27+
28+
29+
methods (Test)
30+
31+
function test_lint(tc, file)
32+
res = checkcode(file, "-config=" + tc.TestData.cfg_file, "-fullpath");
33+
34+
for j = 1:length(res)
35+
tc.verifyFail(append(file, ":", int2str(res(j).line), " ", res(j).message))
36+
end
37+
end
38+
39+
end
40+
41+
end
42+
43+
44+
function filenames = get_files()
45+
cwd = fileparts(mfilename('fullpath'));
46+
flist = dir(fullfile(cwd, '/**/*.m'));
47+
for i = 1:length(flist)
48+
filenames{i} = fullfile(flist(i).folder, flist(i).name); %#ok<AGROW>
49+
end
50+
end

+matmap3d/referenceEllipsoid.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
function e = referenceEllipsoid(name, lengthUnit)
2323
arguments
2424
name (1,1) string = "wgs84"
25-
lengthUnit (1,1) string {mustBeMember(lengthUnit, ["m", "meters"])} = "m"
25+
lengthUnit (1,1) string = "m"
2626
end
2727

28+
mustBeMember(lengthUnit, ["m", "meters"])
29+
2830
switch name
2931
case 'wgs84'
3032
%% WGS-84 ellipsoid parameters.

+matmap3d/unitTest.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,6 @@ function test_ecef2eci(tc)
272272
utc = datetime(2019, 1, 4, 12,0,0);
273273
[x,y,z] = matmap3d.ecef2eci(utc, ecef(1), ecef(2), ecef(3));
274274
tc.verifyEqual([x,y,z], [-2.9818e6, 5.2070e6, 3.1616e6], 'RelTol', 0.01)
275-
276-
[x,y,z] = matmap3d.geodetic2ecef([], 0, 0, 0);
277-
t = datetime(2000, 1, 1, 12, 0, 0, 'TimeZone', 'UTCLeapSeconds');
278-
[eci_x, eci_y, eci_z] = matmap3d.ecef2eci(t, x, y, z);
279275
end
280276

281277
function test_ecef2eci_multiple(tc)

+matmap3d/vdist.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
lambdaold(notdone) = lambda(notdone);
126126
sinsigma(notdone) = sqrt((cos(U2(notdone)).*sin(lambda(notdone)))...
127127
.^2+(cos(U1(notdone)).*sin(U2(notdone))-sin(U1(notdone)).*...
128-
cos(U2(notdone)).*cos(lambda(notdone))).^2);
128+
cos(U2(notdone)).*cos(lambda(notdone))).^2); %#ok<*AGROW>
129129
cossigma(notdone) = sin(U1(notdone)).*sin(U2(notdone))+...
130130
cos(U1(notdone)).*cos(U2(notdone)).*cos(lambda(notdone));
131131
% eliminate rare imaginary portions at limit of numerical precision:
@@ -177,7 +177,6 @@
177177
varargout{2} = reshape(rad2deg(a12),keepsize); % to degrees
178178
end
179179
if nargout > 2
180-
a21=NaN*lat1;
181180
% From point #2 to point #1
182181
% correct sign of lambda for azimuth calcs:
183182
lambda = abs(lambda);

0 commit comments

Comments
 (0)