File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ classdef TestVersion < matlab .unittest .TestCase
2
+
3
+ methods (Test )
4
+
5
+ function test_version(tc )
6
+ tc .verifyTrue(stdlib .version_atleast(" 3.19.0.33" , " 3.19.0" ))
7
+ tc .verifyFalse(stdlib .version_atleast(" 3.19.0.33" , " 3.19.0.34" ))
8
+ end
9
+
10
+ end
11
+
12
+ end
Original file line number Diff line number Diff line change
1
+ function r = cmake_atleast(min_version )
2
+ arguments
3
+ min_version (1 ,1 ) string {mustBeNonzeroLengthText }
4
+ end
5
+
6
+ [ret , msg ] = system(" cmake --version" );
7
+
8
+ assert(ret == 0 , " problem getting CMake version " + msg )
9
+
10
+ match = regexp(msg , " (?<=cmake version )(\d+\.\d+\.\d+)" , ' match' );
11
+
12
+ r = stdlib .version_atleast(match{1 }, min_version );
13
+
14
+ end
Original file line number Diff line number Diff line change
1
+ function r = version_atleast(in , ref )
2
+ % compare two string verions: major.minor.rev.patch
3
+ % uses strings to compare so mixed number/string is OK
4
+ %
5
+ % parameters
6
+ % ------------
7
+ % in: version to examine (string)
8
+ % ref: version to compare against (at least this version is true)
9
+ %
10
+ % returns
11
+ % -------
12
+ % r: logical
13
+
14
+ arguments
15
+ in (1 ,1 ) string
16
+ ref (1 ,1 ) string
17
+ end
18
+
19
+ in = split(in , ' ' );
20
+ in = split(in(1 ), ' .' );
21
+
22
+ ref = split(ref , ' .' );
23
+
24
+ for i = 1 : min(length(in ), length(ref ))
25
+ if in(i ) > ref(i )
26
+ r = true ;
27
+ return
28
+ elseif in(i ) < ref(i )
29
+ r = false ;
30
+ return
31
+ end
32
+ end
33
+
34
+ r = in(end ) >= ref(end );
35
+
36
+ end % function
You can’t perform that action at this time.
0 commit comments