From f736533933f7592b5629d7dc200ab9e1fea3e584 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Sun, 14 Jan 2024 20:27:53 -0800 Subject: [PATCH] further mule_main coverage --- src/mule/mule_main.cpp | 50 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/mule/mule_main.cpp b/src/mule/mule_main.cpp index eca690dd..eed3f726 100644 --- a/src/mule/mule_main.cpp +++ b/src/mule/mule_main.cpp @@ -1317,7 +1317,53 @@ extended_type_coverage_eval_tests(void){ } //////////////////////////////// -// NOTE(allen): C Type Coverage +//~ rjf: Templated Function Eval Tests + +typedef struct TemplateArg TemplateArg; +struct TemplateArg +{ + int x; + int y; + int z; + float a; + float b; + float c; + char *name; +}; + +template static T +templated_factorial(T t) +{ + T result = t; + if(t > 1) + { + result *= templated_factorial(t-1); + } + return result; +} + +template static T +compute_template_arg_info(T t) +{ + int sum = t.x + t.y + t.z; + int size = sizeof(t); + float sum_f = t.a + t.b + t.c; + OutputDebugStringA(t.name); + return t; +} + +static void +templated_function_eval_tests(void) +{ + int int_factorial = templated_factorial(10); + float float_factorial = templated_factorial(10); + TemplateArg arg = {1, 2, 3, 4.f, 5.f, 6.f, "my template arg"}; + compute_template_arg_info(arg); + int x = 0; +} + +//////////////////////////////// +//~ NOTE(allen): C Type Coverage extern "C"{ #include "mule_c.h" @@ -2343,6 +2389,8 @@ mule_main(int argc, char** argv){ extended_type_coverage_eval_tests(); + templated_function_eval_tests(); + c_type_coverage_eval_tests(); c_type_with_bitfield_usage();