Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move normalize_newlines from test to parser #27

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/minja/minja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ class Parser {
public:

static std::shared_ptr<TemplateNode> parse(const std::string& template_str, const Options & options) {
Parser parser(std::make_shared<std::string>(template_str), options);
Parser parser(std::make_shared<std::string>(normalize_newlines(template_str)), options);
auto tokens = parser.tokenize();
TemplateTokenIterator begin = tokens.begin();
auto it = begin;
Expand Down
4 changes: 2 additions & 2 deletions tests/test-chat-template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static std::string read_file(const std::string &path) {
std::string out;
out.resize(static_cast<size_t>(size));
fs.read(&out[0], static_cast<std::streamsize>(size));
return minja::normalize_newlines(out);
return out;
}

int main(int argc, char *argv[]) {
Expand Down Expand Up @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) {

std::string expected;
try {
expected = read_file(golden_file);
expected = minja::normalize_newlines(read_file(golden_file));
} catch (const std::exception &e) {
std::cerr << "Failed to read golden file: " << golden_file << std::endl;
std::cerr << e.what() << std::endl;
Expand Down
Loading