Add test for ODR violations such as forgetting to inline a function in a header. Thanks to STL for pointing out this testing technique.

This commit is contained in:
Beman 2014-07-25 17:58:15 -04:00
parent feffecb67f
commit e8c90f7f15
5 changed files with 146 additions and 0 deletions

View File

@ -18,6 +18,7 @@ project
test-suite "filesystem" : test-suite "filesystem" :
[ run convenience_test.cpp ] [ run convenience_test.cpp ]
[ compile macro_default_test.cpp ] [ compile macro_default_test.cpp ]
[ run odr1_test.cpp odr2_test.cpp ]
[ run deprecated_test.cpp ] [ run deprecated_test.cpp ]
[ run fstream_test.cpp ] [ run fstream_test.cpp ]
[ run large_file_support_test.cpp ] [ run large_file_support_test.cpp ]

View File

@ -119,6 +119,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "recurse_dir_iter_test", "re
{FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1} {FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odr_test", "odr_test\odr_test.vcxproj", "{1F1C209D-105B-4C8A-8DFC-ABCC4D9A0014}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@ -245,6 +247,10 @@ Global
{C6594EC2-1BDA-41A1-B2C0-7FB8AE713CF8}.Debug|Win32.Build.0 = Debug|Win32 {C6594EC2-1BDA-41A1-B2C0-7FB8AE713CF8}.Debug|Win32.Build.0 = Debug|Win32
{C6594EC2-1BDA-41A1-B2C0-7FB8AE713CF8}.Release|Win32.ActiveCfg = Release|Win32 {C6594EC2-1BDA-41A1-B2C0-7FB8AE713CF8}.Release|Win32.ActiveCfg = Release|Win32
{C6594EC2-1BDA-41A1-B2C0-7FB8AE713CF8}.Release|Win32.Build.0 = Release|Win32 {C6594EC2-1BDA-41A1-B2C0-7FB8AE713CF8}.Release|Win32.Build.0 = Release|Win32
{1F1C209D-105B-4C8A-8DFC-ABCC4D9A0014}.Debug|Win32.ActiveCfg = Debug|Win32
{1F1C209D-105B-4C8A-8DFC-ABCC4D9A0014}.Debug|Win32.Build.0 = Debug|Win32
{1F1C209D-105B-4C8A-8DFC-ABCC4D9A0014}.Release|Win32.ActiveCfg = Release|Win32
{1F1C209D-105B-4C8A-8DFC-ABCC4D9A0014}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1F1C209D-105B-4C8A-8DFC-ABCC4D9A0014}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>odr_test</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\odr1_test.cpp" />
<ClCompile Include="..\..\odr2_test.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\filesystem_dll\filesystem_dll.vcxproj">
<Project>{ffd738f7-96f0-445c-81ea-551665ef53d1}</Project>
</ProjectReference>
<ProjectReference Include="..\system_dll\system_dll.vcxproj">
<Project>{f94ccadd-a90b-480c-a304-c19d015d36b1}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

24
test/odr1_test.cpp Normal file
View File

@ -0,0 +1,24 @@
// Boost Filesystem odr1_test.cpp ----------------------------------------------------//
// Copyright Beman Dawes 2014.
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// Library home page: http://www.boost.org/libs/filesystem
#include <boost/filesystem.hpp>
namespace boost
{
namespace filesystem
{
void tu2();
}
}
int main()
{
boost::filesystem::tu2();
return 0;
}

18
test/odr2_test.cpp Normal file
View File

@ -0,0 +1,18 @@
// Boost Filesystem odr2_test.cpp ----------------------------------------------------//
// Copyright Beman Dawes 2014.
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// Library home page: http://www.boost.org/libs/filesystem
#include <boost/filesystem.hpp>
namespace boost
{
namespace filesystem
{
void tu2() {}
}
}