Skip to content

Commit

Permalink
Test using a specialization from a dependent module
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dobrev <[email protected]>
  • Loading branch information
ddobrev committed Nov 24, 2020
1 parent 83e3874 commit 6acaf24
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
19 changes: 19 additions & 0 deletions tests/NamespacesBase/NamespacesBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class DLL_API Abstract
template <typename T>
class TemplateClass
{
public:
T getField() const;
void setField(const T& value);
private:
union
{
int i;
Expand All @@ -59,6 +63,18 @@ class TemplateClass
T t;
};

template <typename T>
T TemplateClass<T>::getField() const
{
return t;
}

template <typename T>
void TemplateClass<T>::setField(const T& value)
{
t = value;
}

template <typename T>
class DLL_API TemplateWithIndependentFields
{
Expand All @@ -84,3 +100,6 @@ class DLL_API SecondaryBase
~SecondaryBase();
void function();
};

// force the symbols for the template instantiations because we do not have the auto-compilation for the generated C++ source
template class DLL_API TemplateClass<int>;
6 changes: 6 additions & 0 deletions tests/NamespacesDerived/NamespacesDerived.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public void TestNonRenamedMethod()
var parent = derived.Parent;
derived.parent(0);
}
using (var derived2 = new Derived2())
{
var template = derived2.Template;
template.Field = 5;
Assert.That(template.Field, Is.EqualTo(5));
}
}

[Test]
Expand Down
13 changes: 13 additions & 0 deletions tests/NamespacesDerived/NamespacesDerived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ void Derived::setNestedNSComponent(OverlappingNamespace::InBaseLib c)
nestedNSComponent = c;
}

Derived2::Derived2()
{
}

Derived2::~Derived2()
{
}

Base3 Derived2::getBase()
{
return baseComponent;
Expand All @@ -57,6 +65,11 @@ void Derived2::defaultEnumValueFromDependency(OverlappingNamespace::ColorsEnum c
{
}

TemplateClass<int> Derived2::getTemplate()
{
return t;
}

Abstract* Derived2::getAbstract()
{
return 0;
Expand Down
5 changes: 4 additions & 1 deletion tests/NamespacesDerived/NamespacesDerived.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ class Base3

template <typename T> class TemplateClass;

class Derived2 : public Base3
class DLL_API Derived2 : public Base3
{
public:
Derived2();
~Derived2();
Base3 baseComponent;
Base3 getBase();
void setBase(Base3);
Expand All @@ -56,6 +58,7 @@ class Derived2 : public Base3
void setNestedNSComponent(OverlappingNamespace::InDerivedLib);
void defaultEnumValueFromDependency(OverlappingNamespace::ColorsEnum c = OverlappingNamespace::ColorsEnum::black);

TemplateClass<int> getTemplate();
Abstract* getAbstract();
private:
TemplateClass<int> t;
Expand Down

0 comments on commit 6acaf24

Please sign in to comment.