MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / test_positions

Function test_positions

subprojects/llama.cpp/tests/test-chat-parser.cpp:575–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573}
574
575static void test_positions() {
576 {
577 common_chat_msg_parser builder("Hello, world!", /* is_partial= */ false, {});
578 assert_equals<size_t>(0, builder.pos());
579 assert_throws([&]() { builder.move_to(100); });
580 assert_equals<size_t>(0, builder.pos());
581 assert_throws([&]() { builder.move_back(1); });
582 assert_equals<size_t>(0, builder.pos());
583
584 builder.move_to(8);
585 assert_equals<size_t>(8, builder.pos());
586 builder.move_back(1);
587 assert_equals<size_t>(7, builder.pos());
588 assert_equals("world!", builder.consume_rest());
589
590 builder.move_to(0);
591 assert_equals<size_t>(0, builder.pos());
592
593 assert_throws([&]() { builder.finish(); });
594 assert_equals<size_t>(0, builder.pos());
595
596 builder.move_to(builder.input().size());
597 builder.finish();
598 }
599 {
600 common_chat_msg_parser builder("Hello, world!", /* is_partial= */ true, {});
601
602 builder.move_to(builder.input().size());
603 assert_equals<size_t>(builder.input().size(), builder.pos());
604 builder.finish();
605 }
606}
607
608int main() {
609 test_positions();

Callers 1

mainFunction · 0.85

Calls 9

assert_throwsFunction · 0.85
move_toMethod · 0.80
move_backMethod · 0.80
consume_restMethod · 0.80
inputMethod · 0.80
assert_equalsFunction · 0.70
sizeMethod · 0.65
posMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected