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

Function test_literals

subprojects/llama.cpp/tests/test-jinja.cpp:707–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

705}
706
707static void test_literals(testing & t) {
708 test_template(t, "integer",
709 "{{ 42 }}",
710 json::object(),
711 "42"
712 );
713
714 test_template(t, "float",
715 "{{ 3.14 }}",
716 json::object(),
717 "3.14"
718 );
719
720 test_template(t, "string",
721 "{{ 'hello' }}",
722 json::object(),
723 "hello"
724 );
725
726 test_template(t, "boolean true",
727 "{{ true }}",
728 json::object(),
729 "True"
730 );
731
732 test_template(t, "boolean false",
733 "{{ false }}",
734 json::object(),
735 "False"
736 );
737
738 test_template(t, "none",
739 "{% if x is none %}null{% endif %}",
740 {{"x", nullptr}},
741 "null"
742 );
743
744 test_template(t, "list literal",
745 "{% for i in [1, 2, 3] %}{{ i }}{% endfor %}",
746 json::object(),
747 "123"
748 );
749
750 test_template(t, "dict literal",
751 "{% set d = {'a': 1} %}{{ d.a }}",
752 json::object(),
753 "1"
754 );
755
756 test_template(t, "integer|abs",
757 "{{ -42 | abs }}",
758 json::object(),
759 "42"
760 );
761
762 test_template(t, "integer|float",
763 "{{ 42 | float }}",
764 json::object(),

Callers

nothing calls this directly

Calls 1

test_templateFunction · 0.85

Tested by

no test coverage detected