Skip to content

Commit

Permalink
refine input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgWoehl committed May 31, 2017
1 parent fdf5280 commit db4101b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions fontexist.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
% Created 2016-01-05 by Jorg C. Woehl
% 2016-12-16 (JCW): Converted to standalone function, comments added.

% input: empty character array, or nonempty character vector
% input: empty character array, or character vector
assert(ischar(font) && (isrow(font) || isempty(font)),...
'fontexist:IncorrectInputType', 'Input must be an empty character array or a nonempty character vector.');
'fontexist:IncorrectInputType', 'Input must be an empty character array or a character vector.');
if isempty(font)
% reduce to simplest empty type
font = '';
Expand All @@ -16,4 +16,4 @@
idx = find(strcmpi(listfonts, font), 1);
bool = ~isempty(idx);

end
end
12 changes: 6 additions & 6 deletions getOSfont.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@

%% Input argument validation

% input 1: empty character array, or nonempty character vector
% input 1: empty character array, or character vector
assert(ischar(OS) && (isrow(OS) || isempty(OS)), 'getOSfont:IncorrectInputType',...
'Input 1 must be an empty character array or a nonempty character vector.');
'Input 1 must be an empty character array or a character vector.');
% convert to all lowercase if necessary
OS = lower(OS);
if isempty(OS)
% reduce to simplest empty type
OS = '';
else
% input 2: (nonempty) numeric vector containing finite real non-negative "integers"
assert(isnumeric(OSVersion) && isvector(OSVersion) && all(isfinite(OSVersion))...
% input 2: nonempty numeric vector containing finite real non-negative "integers"
assert(isnumeric(OSVersion) && ~isempty(OSVersion) && isvector(OSVersion) && all(isfinite(OSVersion))...
&& isreal(OSVersion) && all(OSVersion == round(OSVersion)) && all(OSVersion >= 0),...
'getOSfont:IncorrectInputType',...
'Input 2 must be a (nonempty) vector containing finite real non-negative integer values (of any numeric type).');
'Input 2 must be a nonempty vector containing finite real non-negative integer values (of any numeric type).');
end

%% Determine system UI font
Expand Down Expand Up @@ -161,4 +161,4 @@
OSFont = '';
end

end
end

0 comments on commit db4101b

Please sign in to comment.