MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / test_msg_diffs_compute

Function test_msg_diffs_compute

smallthinker/tests/test-chat.cpp:1346–1428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1344}
1345
1346static void test_msg_diffs_compute() {
1347 printf("[%s]\n", __func__);
1348 {
1349 common_chat_msg msg1;
1350
1351 common_chat_msg msg2;
1352 msg2.content = "Hello, world!";
1353
1354 common_chat_msg_diff diff;
1355 diff.content_delta = "Hello, world!";
1356
1357 assert_equals(
1358 {diff},
1359 common_chat_msg_diff::compute_diffs(msg1, msg2));
1360 }
1361 {
1362 common_chat_msg msg1;
1363 msg1.content = "Hello,";
1364
1365 common_chat_msg msg2;
1366 msg2.content = "Hello, world!";
1367
1368 common_chat_msg_diff diff;
1369 diff.content_delta = " world!";
1370
1371 assert_equals(
1372 {diff},
1373 common_chat_msg_diff::compute_diffs(msg1, msg2));
1374 }
1375 {
1376 common_chat_msg msg0;
1377
1378 common_chat_msg msg1;
1379 msg1.tool_calls = { { "special_function", "{\"ar", /* .id = */ "123" } };
1380
1381 common_chat_msg msg2;
1382 msg2.tool_calls = { { "special_function", "{\"arg1\": 1}", /* .id = */ "123" } };
1383
1384 common_chat_msg_diff diff01;
1385 diff01.tool_call_index = 0;
1386 diff01.tool_call_delta.name = "special_function";
1387 diff01.tool_call_delta.id = "123";
1388 diff01.tool_call_delta.arguments = "{\"ar";
1389
1390 assert_equals(
1391 {diff01},
1392 common_chat_msg_diff::compute_diffs(msg0, msg1));
1393
1394 common_chat_msg_diff diff12;
1395 diff12.tool_call_index = 0;
1396 // Note: neither id nor name change here.
1397 diff12.tool_call_delta.arguments = "g1\": 1}";
1398
1399 assert_equals(
1400 {diff12},
1401 common_chat_msg_diff::compute_diffs(msg1, msg2));
1402 }
1403 {

Callers 1

mainFunction · 0.85

Calls 2

printfFunction · 0.85
assert_equalsFunction · 0.70

Tested by

no test coverage detected