diff --git a/tests/CSharp/CSharp.Tests.cs b/tests/CSharp/CSharp.Tests.cs index 66e469a9..a24c582a 100644 --- a/tests/CSharp/CSharp.Tests.cs +++ b/tests/CSharp/CSharp.Tests.cs @@ -1900,4 +1900,12 @@ public unsafe class CSharpTests { return type.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Any(x => x.Name.Contains("NativeToManaged")); } + + [Test] + public void TestFunctionTemplate() + { + Assert.That(CSharpTemplates.FunctionTemplate(5.0), Is.EqualTo(5 + 4.2)); + Assert.That(CSharpTemplates.FunctionTemplate(6f), Is.EqualTo(6 + 4.1f)); + Assert.That(CSharpTemplates.FunctionTemplate(7), Is.EqualTo(7 + 4)); + } } diff --git a/tests/CSharp/CSharpTemplates.h b/tests/CSharp/CSharpTemplates.h index b25d902d..42aa03ed 100644 --- a/tests/CSharp/CSharpTemplates.h +++ b/tests/CSharp/CSharpTemplates.h @@ -945,6 +945,22 @@ public: }; const FloatArrayF<6> I6{ 1., 1., 1., 0., 0., 0. }; +template +DLL_API inline T FunctionTemplate(T value) { + if (std::is_same::value) + return 4.2 + value; + else if (std::is_same::value) + return 4.1 + value; + return 4 + value; +} + +inline void FunctionTemplateInstantiation() +{ + FunctionTemplate({}); + FunctionTemplate({}); + FunctionTemplate({}); +} + // KEEP ORDER OTHERWISE TEST WONT WORK namespace IncompleteClassTemplatesTests { @@ -962,4 +978,4 @@ namespace IncompleteClassTemplatesTests { StructT> st; }; -} \ No newline at end of file +}