Skip to content

Commit 20f56a0

Browse files
committed
use printf
1 parent 2538411 commit 20f56a0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/test-chat-template.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <iostream>
21
#include <string>
32
#include <vector>
43
#include <sstream>
@@ -133,19 +132,21 @@ int main(void) {
133132
);
134133
formatted_chat.resize(res);
135134
std::string output(formatted_chat.data(), formatted_chat.size());
136-
std::cout << output << "\n-------------------------\n";
135+
printf("%s\n", output.c_str());
136+
printf("-------------------------\n");
137137
assert(output == expected);
138138
}
139139

140140

141141
// test llama_chat_format_single for system message
142-
std::cout << "\n\n=== llama_chat_format_single (system message) ===\n\n";
142+
printf("\n\n=== llama_chat_format_single (system message) ===\n\n");
143143
std::vector<llama_chat_msg> chat2;
144144
llama_chat_msg sys_msg{"system", "You are a helpful assistant"};
145145

146146
auto fmt_sys = [&](std::string tmpl) {
147147
auto output = llama_chat_format_single(nullptr, tmpl, chat2, sys_msg, false);
148-
std::cout << "fmt_sys(" << tmpl << ")\n" << output << "\n-------------------------\n";
148+
printf("fmt_sys(%s) : %s\n", tmpl.c_str(), output.c_str());
149+
printf("-------------------------\n", output.c_str());
149150
return output;
150151
};
151152
assert(fmt_sys("chatml") == "<|im_start|>system\nYou are a helpful assistant<|im_end|>\n");
@@ -155,15 +156,16 @@ int main(void) {
155156

156157

157158
// test llama_chat_format_single for user message
158-
std::cout << "\n\n=== llama_chat_format_single (user message) ===\n\n";
159+
printf("\n\n=== llama_chat_format_single (user message) ===\n\n");
159160
chat2.push_back({"system", "You are a helpful assistant"});
160161
chat2.push_back({"user", "Hello"});
161162
chat2.push_back({"assistant", "I am assistant"});
162163
llama_chat_msg new_msg{"user", "How are you"};
163164

164165
auto fmt_single = [&](std::string tmpl) {
165166
auto output = llama_chat_format_single(nullptr, tmpl, chat2, new_msg, true);
166-
std::cout << "fmt_single(" << tmpl << ")\n" << output << "\n-------------------------\n";
167+
printf("fmt_single(%s) : %s\n", tmpl.c_str(), output.c_str());
168+
printf("-------------------------\n", output.c_str());
167169
return output;
168170
};
169171
assert(fmt_single("chatml") == "\n<|im_start|>user\nHow are you<|im_end|>\n<|im_start|>assistant\n");

0 commit comments

Comments
 (0)