function mesg_object = warn_on_precision_loss(simData)
% Copyright 2017 The MathWorks, Inc.
%
% Function to return a message object if any input value in simData will
% lose precision when cast to double datatype, while creating Signal
% Builder block in a harness. This message object may be used to display
% warning or log information (g1583531).

mesg_object = [];

test_inport_pairs = util_is_precision_lost(simData);
if ~isempty(test_inport_pairs)
    arg_string = '';
    [numRows, ~] = size(test_inport_pairs);
    for i = 1:numRows
        arg_string = [arg_string getString(message('Sldv:MAKEHARNESS:TestCase'))...
                      ' ' num2str(test_inport_pairs(i, 1))...
                      ': ' getString(message('Sldv:MAKEHARNESS:Inport'))...
                      ' ' num2str(test_inport_pairs(i, 2))]; %#ok<AGROW>
        if i < numRows
            arg_string = [arg_string ', ']; %#ok<AGROW>
        else
            arg_string = [arg_string '.']; %#ok<AGROW>
        end
    end
    mesg_object = message('Sldv:MAKEHARNESS:NotPreciselyRepresentableAsDouble', arg_string);
end