Skip to content

Commit

Permalink
added deriving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glensand committed Mar 25, 2021
1 parent 0afd30a commit 7b4ef46
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 0 deletions.
16 changes: 16 additions & 0 deletions v110/base_class_110.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "base_class_110.h"

base_class_110::base_class_110() {
str = "ultimately long test string for memory corruption";
for (std::size_t i = 0 ; i < 100; ++i)
vec.push_back(str);
}

base_class_110::~base_class_110() {
for (auto&& f : fun)
f();
}

void base_class_110::add_fun(const std::function<void()>& f) {
fun.push_back(f);
}
28 changes: 28 additions & 0 deletions v110/base_class_110.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Copyright (C) 2020 - 2021 Gleb Bezborodov - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
*
* You should have received a copy of the MIT license with
* this file. If not, please write to: [email protected], or visit : https://github.com/glensand/visual-studio-compatibility
*/

#pragma once

#include "export.h"
#include <vector>
#include <string>
#include <functional>

class base_class_110 {
public:
API base_class_110();
virtual API ~base_class_110();

void API add_fun(const std::function<void()>& f);
protected:
std::vector<std::string> vec;
private:
std::string str;
std::vector<std::function<void()>> fun;
};

8 changes: 8 additions & 0 deletions v110/export_class_110.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Copyright (C) 2021 Gleb Bezborodov - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
*
* You should have received a copy of the MIT license with
* this file. If not, please write to: [email protected], or visit : https://github.com/glensand/visual-studio-compatibility
*/

#include "export_class_110.h"
#include <iostream>

Expand Down
2 changes: 2 additions & 0 deletions v110/vs2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="base_class_110.h" />
<ClInclude Include="export.h" />
<ClInclude Include="export_class_110.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="base_class_110.cpp" />
<ClCompile Include="export_class_110.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
6 changes: 6 additions & 0 deletions v110/vs2012.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
<ClInclude Include="export_class_110.h">
<Filter>export</Filter>
</ClInclude>
<ClInclude Include="base_class_110.h">
<Filter>export</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="export_class_110.cpp">
<Filter>export</Filter>
</ClCompile>
<ClCompile Include="base_class_110.cpp">
<Filter>export</Filter>
</ClCompile>
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions v142/derived_class_142.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "derived_class_142.h"
#include <iostream>

derived_class_142::derived_class_142() {
one_more_string = "ultimately long test string for memory corruption";

// invalid code
//add_fun([=] { std::cout << one_more_string << std::endl; });
//add_fun([=]
//{
// for (auto&& str : vec)
// std::cout << str << std::endl;
//});
}
19 changes: 19 additions & 0 deletions v142/derived_class_142.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Copyright (C) 2021 Gleb Bezborodov - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
*
* You should have received a copy of the MIT license with
* this file. If not, please write to: [email protected], or visit : https://github.com/glensand/visual-studio-compatibility
*/

#pragma once

#include "v110/base_class_110.h"

class derived_class_142 final : public base_class_110 {
public:
derived_class_142();

private:
std::string one_more_string;
};
3 changes: 3 additions & 0 deletions v142/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "v110/export_class_110.h"
#include "v141/export_class_141.h"
#include "v142/derived_class_142.h"

int main()
{
Expand All @@ -19,5 +20,7 @@ int main()
auto* export_141 = export_class_141::create();
delete export_141;

derived_class_142 instance;

return 0;
}
5 changes: 5 additions & 0 deletions v142/vs2019.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="derived_class_142.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="derived_class_142.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{8177FFC6-CF66-44B6-963C-71F98CFA21D8}</ProjectGuid>
Expand Down Expand Up @@ -76,6 +80,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
Expand Down
8 changes: 8 additions & 0 deletions v142/vs2019.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@
<ClCompile Include="main.cpp">
<Filter>app</Filter>
</ClCompile>
<ClCompile Include="derived_class_142.cpp">
<Filter>app</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="derived_class_142.h">
<Filter>app</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 7b4ef46

Please sign in to comment.