| 1087 | } |
| 1088 | |
| 1089 | static void test_string_methods(testing & t) { |
| 1090 | test_template(t, "string.upper()", |
| 1091 | "{{ s.upper() }}", |
| 1092 | {{"s", "hello"}}, |
| 1093 | "HELLO" |
| 1094 | ); |
| 1095 | |
| 1096 | test_template(t, "string.lower()", |
| 1097 | "{{ s.lower() }}", |
| 1098 | {{"s", "HELLO"}}, |
| 1099 | "hello" |
| 1100 | ); |
| 1101 | |
| 1102 | test_template(t, "string.strip()", |
| 1103 | "[{{ s.strip() }}]", |
| 1104 | {{"s", " hello "}}, |
| 1105 | "[hello]" |
| 1106 | ); |
| 1107 | |
| 1108 | test_template(t, "string.lstrip()", |
| 1109 | "[{{ s.lstrip() }}]", |
| 1110 | {{"s", " hello"}}, |
| 1111 | "[hello]" |
| 1112 | ); |
| 1113 | |
| 1114 | test_template(t, "string.rstrip()", |
| 1115 | "[{{ s.rstrip() }}]", |
| 1116 | {{"s", "hello "}}, |
| 1117 | "[hello]" |
| 1118 | ); |
| 1119 | |
| 1120 | test_template(t, "string.title()", |
| 1121 | "{{ s.title() }}", |
| 1122 | {{"s", "hello world"}}, |
| 1123 | "Hello World" |
| 1124 | ); |
| 1125 | |
| 1126 | test_template(t, "string.capitalize()", |
| 1127 | "{{ s.capitalize() }}", |
| 1128 | {{"s", "heLlo World"}}, |
| 1129 | "Hello world" |
| 1130 | ); |
| 1131 | |
| 1132 | test_template(t, "string.startswith() true", |
| 1133 | "{% if s.startswith('hel') %}yes{% endif %}", |
| 1134 | {{"s", "hello"}}, |
| 1135 | "yes" |
| 1136 | ); |
| 1137 | |
| 1138 | test_template(t, "string.startswith() false", |
| 1139 | "{% if s.startswith('xyz') %}yes{% else %}no{% endif %}", |
| 1140 | {{"s", "hello"}}, |
| 1141 | "no" |
| 1142 | ); |
| 1143 | |
| 1144 | test_template(t, "string.endswith() true", |
| 1145 | "{% if s.endswith('lo') %}yes{% endif %}", |
| 1146 | {{"s", "hello"}}, |
nothing calls this directly
no test coverage detected