git subrepo clone git@github.com:compihu/platform-test-f4-ll.git platforms/platform-test-f4-ll
subrepo: subdir: "platforms/platform-test-f4-ll" merged: "bc41134" upstream: origin: "git@github.com:compihu/platform-test-f4-ll.git" branch: "master" commit: "bc41134" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "87ee373"
This commit is contained in:
parent
46ce55c6a0
commit
95af4ce0d8
460 changed files with 84105 additions and 0 deletions
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/IEEE754ExceptionsPlugin.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
|
||||
class MyDummyComparator : public MockNamedValueComparator
|
||||
{
|
||||
public:
|
||||
virtual bool isEqual(const void* object1, const void* object2)
|
||||
{
|
||||
return object1 == object2;
|
||||
}
|
||||
|
||||
virtual SimpleString valueToString(const void* object)
|
||||
{
|
||||
return StringFrom(object);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
MyDummyComparator dummyComparator;
|
||||
MockSupportPlugin mockPlugin;
|
||||
IEEE754ExceptionsPlugin ieee754Plugin;
|
||||
|
||||
mockPlugin.installComparator("MyDummyType", dummyComparator);
|
||||
TestRegistry::getCurrentRegistry()->installPlugin(&mockPlugin);
|
||||
TestRegistry::getCurrentRegistry()->installPlugin(&ieee754Plugin);
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
#include "AllTests.h"
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
IMPORT_TEST_GROUP( Printer);
|
||||
IMPORT_TEST_GROUP( CircularBuffer);
|
||||
IMPORT_TEST_GROUP( HelloWorld);
|
||||
IMPORT_TEST_GROUP( EventDispatcher);
|
||||
IMPORT_TEST_GROUP( MockDocumentation);
|
|
@ -0,0 +1,252 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="AllTests"
|
||||
ProjectGUID="{95A5F8D0-12C0-4AC1-B46B-292DD3886108}"
|
||||
TargetFrameworkVersion="0"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="./$(ConfigurationName)/"
|
||||
IntermediateDirectory="./$(ConfigurationName)/"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
BuildLogFile="$(IntDir)/BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/AllTests.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories="../../include,../../include/Platforms/VisualCpp,../ApplicationLib"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="3"
|
||||
PrecompiledHeaderFile="./$(ConfigurationName)/AllTests.pch"
|
||||
AssemblerListingLocation="./$(ConfigurationName)/"
|
||||
ObjectFile="./$(ConfigurationName)/"
|
||||
ProgramDataBaseFileName="./$(ConfigurationName)/"
|
||||
XMLDocumentationFileName="./$(ConfigurationName)/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/NODEFAULTLIB:LIBCMT"
|
||||
AdditionalDependencies="../../lib/CppUTest.lib ../ApplicationLib/$(ConfigurationName)/ApplicationLib.lib odbc32.lib odbccp32.lib winmm.lib"
|
||||
OutputFile="./$(ConfigurationName)/AllTests.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
ManifestFile="./$(ConfigurationName)/$(TargetFileName).intermediate.manifest"
|
||||
IgnoreAllDefaultLibraries="false"
|
||||
GenerateDebugInformation="false"
|
||||
ProgramDatabaseFile=""
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\$(ConfigurationName)/AllTests.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine=""$(TargetPath)""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/AllTests.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include,../../include/Platforms/VisualCpp,../ApplicationLib"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
PrecompiledHeaderFile="./$(ConfigurationName)/AllTests.pch"
|
||||
AssemblerListingLocation="./$(ConfigurationName)/"
|
||||
ObjectFile="./$(ConfigurationName)/"
|
||||
ProgramDataBaseFileName="./$(ConfigurationName)/"
|
||||
XMLDocumentationFileName="$(ConfigurationName)/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="../../lib/CppUTest.lib ../ApplicationLib/$(ConfigurationName)/ApplicationLib.lib odbc32.lib odbccp32.lib winmm.lib"
|
||||
OutputFile="./$(ConfigurationName)/AllTests.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
ManifestFile="./$(ConfigurationName)/$(TargetFileName).intermediate.manifest"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="./$(ConfigurationName)/AllTests.pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\Debug/AllTests.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine=""$(TargetPath)""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\AllTests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CircularBufferTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\EventDispatcherTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\HelloTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MockDocumentationTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PrinterTest.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,168 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.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>{95A5F8D0-12C0-4AC1-B46B-292DD3886108}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">./$(Configuration)/\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">./$(Configuration)/\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<BuildLog>
|
||||
<Path>$(IntDir)BuildLog.htm</Path>
|
||||
</BuildLog>
|
||||
<Midl>
|
||||
<TypeLibraryName>.\Debug/AllTests.tlb</TypeLibraryName>
|
||||
<HeaderFileName>
|
||||
</HeaderFileName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories>../../include;../ApplicationLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeaderOutputFile>./$(Configuration)/AllTests.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>./$(Configuration)/</AssemblerListingLocation>
|
||||
<ObjectFileName>./$(Configuration)/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>./$(Configuration)/</ProgramDataBaseFileName>
|
||||
<XMLDocumentationFileName>./$(Configuration)/</XMLDocumentationFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>
|
||||
</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>/NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRTD %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>../../lib/CppUTest.lib;../ApplicationLib/$(Configuration)/ApplicationLib.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>./$(Configuration)/AllTests.exe</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ManifestFile>./$(Configuration)/$(TargetFileName).intermediate.manifest</ManifestFile>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>
|
||||
</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\$(Configuration)/AllTests.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<PostBuildEvent>
|
||||
<Command>"$(TargetPath)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Midl>
|
||||
<TypeLibraryName>.\Debug/AllTests.tlb</TypeLibraryName>
|
||||
<HeaderFileName>
|
||||
</HeaderFileName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../../include;../ApplicationLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeaderOutputFile>./$(Configuration)/AllTests.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>./$(Configuration)/</AssemblerListingLocation>
|
||||
<ObjectFileName>./$(Configuration)/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>./$(Configuration)/</ProgramDataBaseFileName>
|
||||
<XMLDocumentationFileName>$(Configuration)/</XMLDocumentationFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>../../lib/CppUTestd.lib;../ApplicationLib/$(Configuration)/ApplicationLib.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>./$(Configuration)/AllTests.exe</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ManifestFile>./$(Configuration)/$(TargetFileName).intermediate.manifest</ManifestFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>./$(Configuration)/AllTests.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Debug/AllTests.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<PostBuildEvent>
|
||||
<Command>"$(TargetPath)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AllTests.cpp" />
|
||||
<ClCompile Include="CircularBufferTest.cpp" />
|
||||
<ClCompile Include="EventDispatcherTest.cpp" />
|
||||
<ClCompile Include="HelloTest.cpp" />
|
||||
<ClCompile Include="MockDocumentationTest.cpp" />
|
||||
<ClCompile Include="PrinterTest.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ApplicationLib\ApplicationLib.vcxproj">
|
||||
<Project>{348076b9-303c-4fe0-9380-17cdf11134a9}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AllTests.h" />
|
||||
<ClInclude Include="MockPrinter.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,15 @@
|
|||
include_directories(../ApplicationLib)
|
||||
|
||||
add_executable(ExampleTests
|
||||
AllTests.cpp
|
||||
CircularBufferTest.cpp
|
||||
EventDispatcherTest.cpp
|
||||
FEDemoTest.cpp
|
||||
HelloTest.cpp
|
||||
MockDocumentationTest.cpp
|
||||
PrinterTest.cpp
|
||||
)
|
||||
|
||||
cpputest_normalize_test_output_location(ExampleTests)
|
||||
target_link_libraries(ExampleTests ApplicationLib CppUTest CppUTestExt)
|
||||
cpputest_buildtime_discover_tests(ExampleTests)
|
|
@ -0,0 +1,260 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "MockPrinter.h"
|
||||
#include "CircularBuffer.h"
|
||||
|
||||
TEST_GROUP(CircularBuffer)
|
||||
{ CircularBuffer* buffer;
|
||||
|
||||
void setup()
|
||||
{
|
||||
buffer = new CircularBuffer();
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
void fillTheQueue(int seed, int howMany)
|
||||
{
|
||||
for (int i = 0; i < howMany; i++)
|
||||
buffer->Put(seed + i);
|
||||
}
|
||||
void removeFromQueue(int howMany)
|
||||
{
|
||||
for (int i = 0; i < howMany; i++)
|
||||
buffer->Get();
|
||||
}
|
||||
};
|
||||
|
||||
TEST(CircularBuffer, EmptyAfterCreation)
|
||||
{
|
||||
CHECK(buffer->IsEmpty());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, NotEmpty)
|
||||
{
|
||||
buffer->Put(10046);
|
||||
CHECK(!buffer->IsEmpty());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, NotEmptyThenEmpty)
|
||||
{
|
||||
buffer->Put(4567);
|
||||
CHECK(!buffer->IsEmpty());
|
||||
buffer->Get();
|
||||
CHECK(buffer->IsEmpty());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, GetPutOneValue)
|
||||
{
|
||||
buffer->Put(4567);
|
||||
LONGS_EQUAL(4567, buffer->Get());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, GetPutAFew)
|
||||
{
|
||||
buffer->Put(1);
|
||||
buffer->Put(2);
|
||||
buffer->Put(3);
|
||||
LONGS_EQUAL(1, buffer->Get());
|
||||
LONGS_EQUAL(2, buffer->Get());
|
||||
LONGS_EQUAL(3, buffer->Get());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, Capacity)
|
||||
{
|
||||
CircularBuffer b(2);
|
||||
LONGS_EQUAL(2, b.Capacity());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, IsFull)
|
||||
{
|
||||
fillTheQueue(0, buffer->Capacity());
|
||||
CHECK(buffer->IsFull());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, EmptyToFullToEmpty)
|
||||
{
|
||||
fillTheQueue(100, buffer->Capacity());
|
||||
|
||||
CHECK(buffer->IsFull());
|
||||
|
||||
removeFromQueue(buffer->Capacity());
|
||||
|
||||
CHECK(buffer->IsEmpty());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, WrapAround)
|
||||
{
|
||||
fillTheQueue(100, buffer->Capacity());
|
||||
|
||||
CHECK(buffer->IsFull());
|
||||
LONGS_EQUAL(100, buffer->Get());
|
||||
CHECK(!buffer->IsFull());
|
||||
buffer->Put(1000);
|
||||
CHECK(buffer->IsFull());
|
||||
|
||||
removeFromQueue(buffer->Capacity() - 1);
|
||||
|
||||
LONGS_EQUAL(1000, buffer->Get());
|
||||
CHECK(buffer->IsEmpty());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, PutToFull)
|
||||
{
|
||||
int capacity = buffer->Capacity();
|
||||
fillTheQueue(900, capacity);
|
||||
buffer->Put(9999);
|
||||
|
||||
for (int i = 0; i < buffer->Capacity() - 1; i++)
|
||||
LONGS_EQUAL(i+900+1, buffer->Get());
|
||||
|
||||
LONGS_EQUAL(9999, buffer->Get());
|
||||
CHECK(buffer->IsEmpty());
|
||||
}
|
||||
|
||||
//Sometime people ask what tests the tests.
|
||||
//Do you know the answer
|
||||
|
||||
|
||||
TEST(CircularBuffer, GetFromEmpty)
|
||||
{
|
||||
LONGS_EQUAL(-1, buffer->Get());
|
||||
CHECK(buffer->IsEmpty());
|
||||
}
|
||||
|
||||
/*
|
||||
* the next tests demonstrate using a mock object for
|
||||
* capturing output
|
||||
*
|
||||
*/
|
||||
|
||||
TEST(CircularBuffer, PrintEmpty)
|
||||
{
|
||||
MockPrinter mock;
|
||||
Printer* p = &mock;
|
||||
|
||||
buffer->Print(p);
|
||||
STRCMP_EQUAL("Circular buffer content:\n<>\n",
|
||||
mock.getOutput().c_str());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, PrintAfterOnePut)
|
||||
{
|
||||
MockPrinter mock;
|
||||
|
||||
buffer->Put(1);
|
||||
buffer->Print(&mock);
|
||||
STRCMP_EQUAL("Circular buffer content:\n<1>\n",
|
||||
mock.getOutput().c_str());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, PrintNotYetWrappedOrFull)
|
||||
{
|
||||
MockPrinter mock;
|
||||
|
||||
buffer->Put(1);
|
||||
buffer->Put(2);
|
||||
buffer->Put(3);
|
||||
buffer->Print(&mock);
|
||||
STRCMP_EQUAL("Circular buffer content:\n<1, 2, 3>\n",
|
||||
mock.getOutput().c_str());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, PrintNotYetWrappedAndIsFull)
|
||||
{
|
||||
MockPrinter mock;
|
||||
|
||||
fillTheQueue(200, buffer->Capacity());
|
||||
|
||||
buffer->Print(&mock);
|
||||
const char* expected = "Circular buffer content:\n"
|
||||
"<200, 201, 202, 203, 204>\n";
|
||||
|
||||
STRCMP_EQUAL(expected, mock.getOutput().c_str());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, PrintWrappedAndIsFullOldestToNewest)
|
||||
{
|
||||
MockPrinter mock;
|
||||
|
||||
fillTheQueue(200, buffer->Capacity());
|
||||
buffer->Get();
|
||||
buffer->Put(999);
|
||||
|
||||
buffer->Print(&mock);
|
||||
const char* expected = "Circular buffer content:\n"
|
||||
"<201, 202, 203, 204, 999>\n";
|
||||
|
||||
STRCMP_EQUAL(expected, mock.getOutput().c_str());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, PrintWrappedAndFullOverwriteOldest)
|
||||
{
|
||||
MockPrinter mock;
|
||||
|
||||
fillTheQueue(200, buffer->Capacity());
|
||||
buffer->Put(9999);
|
||||
|
||||
buffer->Print(&mock);
|
||||
const char* expected = "Circular buffer content:\n"
|
||||
"<201, 202, 203, 204, 9999>\n";
|
||||
|
||||
STRCMP_EQUAL(expected, mock.getOutput().c_str());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, PrintBoundary)
|
||||
{
|
||||
MockPrinter mock;
|
||||
|
||||
fillTheQueue(200, buffer->Capacity());
|
||||
removeFromQueue(buffer->Capacity() - 2);
|
||||
buffer->Put(888);
|
||||
fillTheQueue(300, buffer->Capacity() - 1);
|
||||
|
||||
buffer->Print(&mock);
|
||||
const char* expected = "Circular buffer content:\n"
|
||||
"<888, 300, 301, 302, 303>\n";
|
||||
|
||||
STRCMP_EQUAL(expected, mock.getOutput().c_str());
|
||||
}
|
||||
|
||||
TEST(CircularBuffer, FillEmptyThenPrint)
|
||||
{
|
||||
MockPrinter mock;
|
||||
|
||||
fillTheQueue(200, buffer->Capacity());
|
||||
removeFromQueue(buffer->Capacity());
|
||||
buffer->Print(&mock);
|
||||
const char* expected = "Circular buffer content:\n"
|
||||
"<>\n";
|
||||
|
||||
STRCMP_EQUAL(expected, mock.getOutput().c_str());
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTestExt/MockSupport.h"
|
||||
#include "EventDispatcher.h"
|
||||
|
||||
class ObserverMock : public EventObserver
|
||||
{
|
||||
public:
|
||||
virtual void notify(const Event& event, int timeOutInSeconds)
|
||||
{
|
||||
mock().actualCall("notify").onObject(this).withParameterOfType("Event", "event", (void*) &event).withParameter("timeOutInSeconds", timeOutInSeconds);
|
||||
}
|
||||
virtual void notifyRegistration(EventObserver* newObserver)
|
||||
{
|
||||
mock().actualCall("notifyRegistration").onObject(this).withParameter("newObserver", newObserver);
|
||||
}
|
||||
};
|
||||
|
||||
class EventComparator : public MockNamedValueComparator
|
||||
{
|
||||
public:
|
||||
virtual bool isEqual(const void* object1, const void* object2)
|
||||
{
|
||||
return ((const Event*)object1)->type == ((const Event*)object2)->type;
|
||||
}
|
||||
virtual SimpleString valueToString(const void* object)
|
||||
{
|
||||
return StringFrom(((const Event*)object)->type);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST_GROUP(EventDispatcher)
|
||||
{
|
||||
Event event;
|
||||
EventDispatcher* dispatcher;
|
||||
ObserverMock observer;
|
||||
ObserverMock observer2;
|
||||
EventComparator eventComparator;
|
||||
|
||||
void setup()
|
||||
{
|
||||
dispatcher = new EventDispatcher;
|
||||
mock().installComparator("Event", eventComparator);
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
delete dispatcher;
|
||||
mock().removeAllComparatorsAndCopiers();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST(EventDispatcher, EventWithoutRegistrationsResultsIntoNoCalls)
|
||||
{
|
||||
dispatcher->dispatchEvent(event, 10);
|
||||
}
|
||||
|
||||
TEST(EventDispatcher, EventWithRegistrationForEventResultsIntoCallback)
|
||||
{
|
||||
mock().expectOneCall("notify").onObject(&observer).withParameterOfType("Event", "event", &event).withParameter("timeOutInSeconds", 10);
|
||||
event.type = IMPORTANT_EVENT;
|
||||
|
||||
dispatcher->registerObserver(IMPORTANT_EVENT, &observer);
|
||||
dispatcher->dispatchEvent(event, 10);
|
||||
}
|
||||
|
||||
TEST(EventDispatcher, DifferentEventWithRegistrationDoesNotResultIntoCallback)
|
||||
{
|
||||
event.type = LESS_IMPORTANT_EVENT;
|
||||
dispatcher->registerObserver(IMPORTANT_EVENT, &observer);
|
||||
dispatcher->dispatchEvent(event, 10);
|
||||
}
|
||||
|
||||
TEST(EventDispatcher, RegisterTwoObserversResultIntoTwoCallsAndARegistrationNotification)
|
||||
{
|
||||
mock().expectOneCall("notify").onObject(&observer).withParameterOfType("Event", "event", &event).withParameter("timeOutInSeconds", 10);
|
||||
mock().expectOneCall("notify").onObject(&observer2).withParameterOfType("Event", "event", &event).withParameter("timeOutInSeconds", 10);
|
||||
mock().expectOneCall("notifyRegistration").onObject(&observer).withParameter("newObserver", &observer2);
|
||||
|
||||
event.type = IMPORTANT_EVENT;
|
||||
dispatcher->registerObserver(IMPORTANT_EVENT, &observer);
|
||||
dispatcher->registerObserver(IMPORTANT_EVENT, &observer2);
|
||||
dispatcher->dispatchEvent(event, 10);
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Michael Feathers, James Grenning, Bas Vodde
|
||||
* and Arnd Strube. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
|
||||
#ifdef CPPUTEST_HAVE_FENV
|
||||
#include "CppUTestExt/IEEE754ExceptionsPlugin.h"
|
||||
|
||||
/*
|
||||
* To see a demonstration of tests failing as a result of IEEE754ExceptionsPlugin
|
||||
* picking up floating point errors, run the test executable with the -ri option.
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <fenv.h>
|
||||
}
|
||||
|
||||
#include <limits>
|
||||
|
||||
static volatile float f;
|
||||
|
||||
TEST_GROUP(FE_Demo)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
IEEE754ExceptionsPlugin::disableInexact();
|
||||
}
|
||||
};
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_DIVBYZERO__is_set)
|
||||
{
|
||||
f = 1.0f;
|
||||
CHECK((f /= 0.0f) >= std::numeric_limits<float>::infinity());
|
||||
}
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_UNDERFLOW__is_set)
|
||||
{
|
||||
f = 0.01f;
|
||||
while (f > 0.0f) f *= f;
|
||||
CHECK(f == 0.0f);
|
||||
}
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_OVERFLOW__is_set)
|
||||
{
|
||||
f = 1000.0f;
|
||||
while (f < std::numeric_limits<float>::infinity()) f *= f;
|
||||
CHECK(f >= std::numeric_limits<float>::infinity());
|
||||
}
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_INEXACT____is_set)
|
||||
{
|
||||
IEEE754ExceptionsPlugin::enableInexact();
|
||||
f = 10.0f;
|
||||
DOUBLES_EQUAL((double) (f / 3.0f), (double) 3.333f, (double) 0.001f);
|
||||
}
|
||||
|
||||
TEST(FE_Demo, should_succeed_when_no_flags_are_set)
|
||||
{
|
||||
CHECK(5.0f == 15.0f / 3.0f);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "hello.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "CppUTest/TestHarness.h"
|
||||
|
||||
static SimpleString* buffer;
|
||||
|
||||
TEST_GROUP(HelloWorld)
|
||||
{ static int output_method(const char* output, ...)
|
||||
{
|
||||
va_list arguments;
|
||||
va_start(arguments, output);
|
||||
*buffer = VStringFromFormat(output, arguments);
|
||||
va_end(arguments);
|
||||
return 1;
|
||||
}
|
||||
void setup()
|
||||
{
|
||||
buffer = new SimpleString();
|
||||
UT_PTR_SET(PrintFormated, &output_method);
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
delete buffer;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(HelloWorld, PrintOk)
|
||||
{
|
||||
printHelloWorld();
|
||||
STRCMP_EQUAL("Hello World!\n", buffer->asCharString());
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTestExt/MockSupport.h"
|
||||
#include "CppUTestExt/MockSupport_c.h"
|
||||
|
||||
TEST_GROUP(FirstTestGroup)
|
||||
{
|
||||
};
|
||||
|
||||
TEST(FirstTestGroup, FirsTest)
|
||||
{
|
||||
// FAIL("Fail me!");
|
||||
}
|
||||
|
||||
TEST(FirstTestGroup, SecondTest)
|
||||
{
|
||||
// STRCMP_EQUAL("hello", "world");
|
||||
}
|
||||
|
||||
|
||||
TEST_GROUP(MockDocumentation)
|
||||
{
|
||||
};
|
||||
|
||||
static void productionCode()
|
||||
{
|
||||
mock().actualCall("productionCode");
|
||||
}
|
||||
|
||||
TEST(MockDocumentation, SimpleScenario)
|
||||
{
|
||||
mock().expectOneCall("productionCode");
|
||||
productionCode();
|
||||
mock().checkExpectations();
|
||||
}
|
||||
|
||||
class ClassFromProductionCode
|
||||
{
|
||||
public:
|
||||
virtual void importantFunction(){}
|
||||
virtual ~ClassFromProductionCode() {}
|
||||
};
|
||||
|
||||
class ClassFromProductionCodeMock : public ClassFromProductionCode
|
||||
{
|
||||
public:
|
||||
virtual void importantFunction()
|
||||
{
|
||||
mock().actualCall("importantFunction").onObject(this);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(MockDocumentation, SimpleScenarioObject)
|
||||
{
|
||||
ClassFromProductionCode* object = new ClassFromProductionCodeMock; /* create mock instead of real thing */
|
||||
|
||||
mock().expectOneCall("importantFunction").onObject(object);
|
||||
object->importantFunction();
|
||||
mock().checkExpectations();
|
||||
|
||||
delete object;
|
||||
}
|
||||
|
||||
static void parameters_function(int p1, const char* p2)
|
||||
{
|
||||
void* object = (void*) 1;
|
||||
mock().actualCall("function").onObject(object).withParameter("p1", p1).withParameter("p2", p2);
|
||||
}
|
||||
|
||||
TEST(MockDocumentation, parameters)
|
||||
{
|
||||
void* object = (void*) 1;
|
||||
mock().expectOneCall("function").onObject(object).withParameter("p1", 2).withParameter("p2", "hah");
|
||||
parameters_function(2, "hah");
|
||||
}
|
||||
|
||||
class MyTypeComparator : public MockNamedValueComparator
|
||||
{
|
||||
public:
|
||||
virtual bool isEqual(const void* object1, const void* object2)
|
||||
{
|
||||
return object1 == object2;
|
||||
}
|
||||
virtual SimpleString valueToString(const void* object)
|
||||
{
|
||||
return StringFrom(object);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(MockDocumentation, ObjectParameters)
|
||||
{
|
||||
void* object = (void*) 1;
|
||||
MyTypeComparator comparator;
|
||||
mock().installComparator("myType", comparator);
|
||||
mock().expectOneCall("function").withParameterOfType("myType", "parameterName", object);
|
||||
mock().clear();
|
||||
mock().removeAllComparatorsAndCopiers();
|
||||
}
|
||||
|
||||
TEST(MockDocumentation, returnValue)
|
||||
{
|
||||
mock().expectOneCall("function").andReturnValue(10);
|
||||
int value = mock().actualCall("function").returnValue().getIntValue();
|
||||
value = mock().returnValue().getIntValue();
|
||||
LONGS_EQUAL(10, value);
|
||||
}
|
||||
|
||||
TEST(MockDocumentation, setData)
|
||||
{
|
||||
ClassFromProductionCode object;
|
||||
mock().setData("importantValue", 10);
|
||||
mock().setDataObject("importantObject", "ClassFromProductionCode", &object);
|
||||
|
||||
ClassFromProductionCode * pobject;
|
||||
int value = mock().getData("importantValue").getIntValue();
|
||||
pobject = (ClassFromProductionCode*) mock().getData("importantObject").getObjectPointer();
|
||||
|
||||
LONGS_EQUAL(10, value);
|
||||
POINTERS_EQUAL(pobject, &object);
|
||||
}
|
||||
|
||||
static void doSomethingThatWouldOtherwiseBlowUpTheMockingFramework()
|
||||
{
|
||||
}
|
||||
|
||||
TEST(MockDocumentation, otherMockSupport)
|
||||
{
|
||||
mock().crashOnFailure();
|
||||
// mock().actualCall("unex");
|
||||
|
||||
mock().expectOneCall("foo");
|
||||
mock().ignoreOtherCalls();
|
||||
|
||||
mock().disable();
|
||||
doSomethingThatWouldOtherwiseBlowUpTheMockingFramework();
|
||||
mock().enable();
|
||||
|
||||
mock().clear();
|
||||
|
||||
}
|
||||
|
||||
TEST(MockDocumentation, scope)
|
||||
{
|
||||
mock("xmlparser").expectOneCall("open");
|
||||
mock("filesystem").ignoreOtherCalls();
|
||||
|
||||
mock("xmlparser").actualCall("open");
|
||||
}
|
||||
|
||||
static int equalMethod(const void* object1, const void* object2)
|
||||
{
|
||||
return object1 == object2;
|
||||
}
|
||||
|
||||
static const char* toStringMethod(const void*)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
|
||||
TEST(MockDocumentation, CInterface)
|
||||
{
|
||||
void* object = (void*) 0x1;
|
||||
|
||||
mock_c()->expectOneCall("foo")->withIntParameters("integer", 10)->andReturnDoubleValue(1.11);
|
||||
double d = mock_c()->actualCall("foo")->withIntParameters("integer", 10)->returnValue().value.doubleValue;
|
||||
DOUBLES_EQUAL(1.11, d, 0.00001);
|
||||
|
||||
|
||||
mock_c()->installComparator("type", equalMethod, toStringMethod);
|
||||
mock_scope_c("scope")->expectOneCall("bar")->withParameterOfType("type", "name", object);
|
||||
mock_scope_c("scope")->actualCall("bar")->withParameterOfType("type", "name", object);
|
||||
mock_c()->removeAllComparatorsAndCopiers();
|
||||
|
||||
mock_c()->setIntData("important", 10);
|
||||
mock_c()->checkExpectations();
|
||||
mock_c()->clear();
|
||||
}
|
||||
|
||||
TEST_GROUP(FooTestGroup)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
// Init stuff
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
// Uninit stuff
|
||||
}
|
||||
};
|
||||
|
||||
TEST(FooTestGroup, Foo)
|
||||
{
|
||||
// Test FOO
|
||||
}
|
||||
|
||||
TEST(FooTestGroup, MoreFoo)
|
||||
{
|
||||
// Test more FOO
|
||||
}
|
||||
|
||||
TEST_GROUP(BarTestGroup)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
// Init Bar
|
||||
}
|
||||
};
|
||||
|
||||
TEST(BarTestGroup, Bar)
|
||||
{
|
||||
// Test Bar
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef D_MockPrinter_H
|
||||
#define D_MockPrinter_H
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MockPrinter.h
|
||||
//
|
||||
// MockPrinter is responsible for providing a test stub for Printer
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "Printer.h"
|
||||
#include "CppUTest/SimpleString.h"
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
class MockPrinter: public Printer
|
||||
{
|
||||
public:
|
||||
explicit MockPrinter()
|
||||
{
|
||||
}
|
||||
virtual ~MockPrinter()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Print(const char* s)
|
||||
{
|
||||
savedOutput.append(s);
|
||||
}
|
||||
|
||||
virtual void Print(long int value)
|
||||
{
|
||||
SimpleString buffer;
|
||||
buffer = StringFromFormat("%ld", value);
|
||||
savedOutput.append(buffer.asCharString());
|
||||
}
|
||||
|
||||
std::string getOutput() const
|
||||
{
|
||||
return savedOutput;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::string savedOutput;
|
||||
|
||||
MockPrinter(const MockPrinter&);
|
||||
MockPrinter& operator=(const MockPrinter&);
|
||||
|
||||
};
|
||||
|
||||
#endif // D_MockPrinter_H
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "Printer.h"
|
||||
#include "MockPrinter.h"
|
||||
|
||||
TEST_GROUP(Printer)
|
||||
{ Printer* printer;
|
||||
MockPrinter* mockPrinter;
|
||||
|
||||
void setup()
|
||||
{
|
||||
mockPrinter = new MockPrinter();
|
||||
printer = mockPrinter;
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
delete printer;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Printer, PrintConstCharStar)
|
||||
{
|
||||
printer->Print("hello");
|
||||
printer->Print("hello\n");
|
||||
const char* expected = "hellohello\n";
|
||||
CHECK_EQUAL(expected, mockPrinter->getOutput());
|
||||
}
|
||||
|
||||
TEST(Printer, PrintLong)
|
||||
{
|
||||
printer->Print(1234);
|
||||
const char* expected = "1234";
|
||||
CHECK_EQUAL(expected, mockPrinter->getOutput());
|
||||
}
|
||||
|
||||
TEST(Printer, StreamOperators)
|
||||
{
|
||||
*printer << "n=" << 1234;
|
||||
const char* expected = "n=1234";
|
||||
CHECK_EQUAL(expected, mockPrinter->getOutput());
|
||||
}
|
||||
|
4
platforms/platform-test-f4-ll/cpputest/examples/AllTests/RunAllTests.sh
Executable file
4
platforms/platform-test-f4-ll/cpputest/examples/AllTests/RunAllTests.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
#put any pre-test execution commands here.
|
||||
echo Running all tests
|
||||
./AllTests $1
|
Loading…
Add table
Add a link
Reference in a new issue