<commit_before>#include <TestSupport.h>
#include <Utils/Template.h>
#include <cstdarg>

using namespace Passenger;

namespace tut {
	struct TemplateTest {
		string apply(const StaticString &templateContent, ...) {
			va_list ap;
			const char *arg;
			StringMap<StaticString> params;

			va_start(ap, templateContent);
			while ((arg = va_arg(ap, const char *)) != NULL) {
				params.set(arg, va_arg(ap, const char *));
			}
			string result = Template::apply(templateContent, params);
			va_end(ap);
			return result;
		}
	};
	
	DEFINE_TEST_GROUP(TemplateTest);
	
	TEST_METHOD(1) {
		// Test 1 substitution.
		string result = apply("hello {{name}}",
			"name", "world",
			NULL);
		ensure_equals(result, "hello world");
	}

	TEST_METHOD(2) {
		// Test multiple substitutions.
		string result = apply("hello {{name}} and {{name2}}",
			"name", "joe",
			"name2", "jane",
			NULL);<commit_msg>Fix incorrect usage of va_args in TemplateTest.<commit_after>#include <TestSupport.h>
#include <Utils/Template.h>
#include <cstdarg>

using namespace Passenger;

namespace tut {
	struct TemplateTest {
		string apply(const char *templateContent, ...) {
			va_list ap;
			const char *arg;
			StringMap<StaticString> params;

			va_start(ap, templateContent);
			while ((arg = va_arg(ap, const char *)) != NULL) {
				params.set(arg, va_arg(ap, const char *));
			}
			string result = Template::apply(templateContent, params);
			va_end(ap);
			return result;
		}
	};
	
	DEFINE_TEST_GROUP(TemplateTest);
	
	TEST_METHOD(1) {
		// Test 1 substitution.
		string result = apply("hello {{name}}",
			"name", "world",
			NULL);
		ensure_equals(result, "hello world");
	}

	TEST_METHOD(2) {
		// Test multiple substitutions.
		string result = apply("hello {{name}} and {{name2}}",
			"name", "joe",
			"name2", "jane",
			NULL);
{'fraction_non_alphanumeric': 0.15303867403314916, 'fraction_numerical': 0.0055248618784530384, 'mean_word_length': 3.948087431693989, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1430181', 'n_tokens_mistral': 704, 'n_tokens_neox': 602, 'n_words': 151}