Last change
on this file was 19105, checked in by Mathieu Morlighem, 10 years ago |
merged trunk-jpl and trunk for revision 19103
|
-
Property svn:executable
set to
*
|
File size:
1.3 KB
|
Rev | Line | |
---|
[5100] | 1 | function name=IdToName(id);
|
---|
| 2 | %IDTONAME- return name of test
|
---|
[19105] | 3 | %
|
---|
| 4 | % if id=0, the full list of test is returned
|
---|
[4950] | 5 | %
|
---|
| 6 | % Usage:
|
---|
[19105] | 7 | % name=IdToName();
|
---|
[5100] | 8 | % name=IdToName(id);
|
---|
[4950] | 9 |
|
---|
[19105] | 10 | if nargin==0 | id==0,
|
---|
| 11 | flist=dir;%use dir, as it seems to act OS independent
|
---|
| 12 | list_ids=[];
|
---|
| 13 | for i=1:numel(flist),
|
---|
| 14 | if ( strncmp(flist(i).name,'test',4) &... %File name must start with 'test'
|
---|
| 15 | strncmp(fliplr(flist(i).name),fliplr('.m'),2)&... %File name must end by '.m'
|
---|
| 16 | ~strcmp(flist(i).name,'test.m')) %File name must be different than 'test.m'
|
---|
| 17 | id=str2num(flist(i).name(5:end-2));
|
---|
| 18 | if isempty(id),
|
---|
| 19 | disp(['WARNING: ignore file ' flist(i).name ]);
|
---|
| 20 | else
|
---|
| 21 | list_ids(end+1)=eval(flist(i).name(5:end-2)); %Keep test id only (skip 'test' and '.m')
|
---|
| 22 | end
|
---|
| 23 | end
|
---|
| 24 | end
|
---|
| 25 | list_ids=sort(list_ids);
|
---|
| 26 | for i=list_ids,
|
---|
| 27 | name=IdToName(i);
|
---|
| 28 | disp(['test ' num2str(i,'%5i\n') ' : ' name]);
|
---|
| 29 | end
|
---|
| 30 | return;
|
---|
| 31 | end
|
---|
[13395] | 32 |
|
---|
[19105] | 33 | filename = ['test' num2str(id) '.m'];
|
---|
[16560] | 34 |
|
---|
[19105] | 35 | if ~exist(filename,'file')
|
---|
| 36 | error(['file ' filename ' does not exist']);
|
---|
[6265] | 37 | end
|
---|
[19105] | 38 |
|
---|
| 39 | string='%TestName:';
|
---|
| 40 | fid=fopen(filename,'r');
|
---|
| 41 | A=fscanf(fid,'%s',3);
|
---|
| 42 | if ~strncmp(A,string,numel(string)) | numel(A)<numel(string)+2,
|
---|
| 43 | error(['Test file ' filename ' does to start with a test name']);
|
---|
| 44 | end
|
---|
| 45 | name = A(numel(string)+1:end);
|
---|
| 46 | fclose(fid);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.