Test functionality of Source helper class

This change introduces unit tests for Source class,
which is a helper of ocloc_arg_helper.

The original functionality has been improved to preserve
last line even if it does not contain trailing new line sign.
Moreover, empty lines are skipped since this change.

Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
Patryk Wrobel
2022-03-24 15:16:01 +00:00
committed by Compute-Runtime-Automation
parent be50afb930
commit 41a8972772
2 changed files with 71 additions and 2 deletions

View File

@ -25,13 +25,19 @@ void Source::toVectorOfStrings(std::vector<std::string> &lines, bool replaceTabs
if (replaceTabs && *file == '\t') {
line += ' ';
} else if (*file == '\n') {
lines.push_back(line);
line = "";
if (!line.empty()) {
lines.push_back(line);
line = "";
}
} else {
line += *file;
}
file++;
}
if (!line.empty()) {
lines.push_back(std::move(line));
}
}
Output::Output(const std::string &name, const void *data, const size_t &size)